Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the ability to the API consumers to load the API implementations … #95

Merged
merged 1 commit into from
Oct 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions api/src/main/java/jakarta/activation/MailcapCommandMap.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2021, 2022 Oracle and/or its affiliates. All rights reserved.
lukasj marked this conversation as resolved.
Show resolved Hide resolved
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
Expand Down 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
19 changes: 14 additions & 5 deletions api/src/main/java/jakarta/activation/MimetypesFileTypeMap.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2021, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
Expand All @@ -10,7 +10,6 @@

package jakarta.activation;

import jakarta.activation.spi.MailcapRegistryProvider;
import jakarta.activation.spi.MimeTypeRegistryProvider;

import java.io.*;
Expand Down Expand Up @@ -386,9 +385,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