Skip to content

Commit

Permalink
Add the ability to the API consumers to load the API implementations …
Browse files Browse the repository at this point in the history
…by using a different protection domain when using with security manager enabled
  • Loading branch information
yersan committed Oct 4, 2022
1 parent 2270d5e commit dfe1018
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
16 changes: 13 additions & 3 deletions api/src/main/java/jakarta/activation/MailcapCommandMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -693,9 +693,19 @@ public synchronized String[] getNativeCommands(String mimeType) {
}

private MailcapRegistryProvider getImplementation() {
return FactoryFinder.find(MailcapRegistryProvider.class,
"com.sun.activation.registries.MailcapRegistryProviderImpl",
false);
if (System.getSecurityManager() != null) {
return AccessController.doPrivileged(new PrivilegedAction<MailcapRegistryProvider>() {
public MailcapRegistryProvider run() {
return FactoryFinder.find(MailcapRegistryProvider.class,
"com.sun.activation.registries.MailcapRegistryProviderImpl",
false);
}
});
} else {
return FactoryFinder.find(MailcapRegistryProvider.class,
"com.sun.activation.registries.MailcapRegistryProviderImpl",
false);
}
}

/*
Expand Down
16 changes: 13 additions & 3 deletions api/src/main/java/jakarta/activation/MimetypesFileTypeMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,19 @@ public synchronized String getContentType(String filename) {
}

private MimeTypeRegistryProvider getImplementation() {
return FactoryFinder.find(MimeTypeRegistryProvider.class,
"com.sun.activation.registries.MimeTypeRegistryProviderImpl",
false);
if (System.getSecurityManager() != null) {
return AccessController.doPrivileged(new PrivilegedAction<MimeTypeRegistryProvider>() {
public MimeTypeRegistryProvider run() {
return FactoryFinder.find(MimeTypeRegistryProvider.class,
"com.sun.activation.registries.MimeTypeRegistryProviderImpl",
false);
}
});
} else {
return FactoryFinder.find(MimeTypeRegistryProvider.class,
"com.sun.activation.registries.MimeTypeRegistryProviderImpl",
false);
}
}

/*
Expand Down

0 comments on commit dfe1018

Please sign in to comment.