8342281: Deprecate for removal javax.sound.sampled.AudioPermission

Reviewed-by: honkar, kizune
This commit is contained in:
Phil Race 2024-11-21 03:58:49 +00:00
parent 4fbf272017
commit a01aa22026
4 changed files with 6 additions and 48 deletions

View File

@ -404,10 +404,6 @@ final class DirectAudioDevice extends AbstractMixer {
// $$fb part of fix for 4679187: Clip.open() throws unexpected Exceptions
Toolkit.isFullySpecifiedAudioFormat(format);
// check for record permission
if (!isSource) {
JSSecurityManager.checkRecordPermission();
}
int encoding = PCM;
if (format.getEncoding().equals(AudioFormat.Encoding.ULAW)) {
encoding = ULAW;
@ -509,11 +505,6 @@ final class DirectAudioDevice extends AbstractMixer {
@Override
void implStart() {
// check for record permission
if (!isSource) {
JSSecurityManager.checkRecordPermission();
}
synchronized (lockNative)
{
nStart(id, isSource);
@ -538,11 +529,6 @@ final class DirectAudioDevice extends AbstractMixer {
@Override
void implStop() {
// check for record permission
if (!isSource) {
JSSecurityManager.checkRecordPermission();
}
if (monitoring) {
getEventDispatcher().removeLineMonitor(this);
monitoring = false;
@ -565,11 +551,6 @@ final class DirectAudioDevice extends AbstractMixer {
@Override
void implClose() {
// check for record permission
if (!isSource) {
JSSecurityManager.checkRecordPermission();
}
// be sure to remove this monitor
if (monitoring) {
getEventDispatcher().removeLineMonitor(this);

View File

@ -35,11 +35,9 @@ import java.util.List;
import java.util.Properties;
import java.util.ServiceLoader;
import javax.sound.sampled.AudioPermission;
/** Managing security in the Java Sound implementation.
* This class contains all code that uses and is used by
* SecurityManager
/**
* Historically this class managed ensuring privileges to access resources
* it is still used to get those resources but no longer does checks.
*
* @author Matthias Pfisterer
*/
@ -50,14 +48,6 @@ final class JSSecurityManager {
private JSSecurityManager() {
}
static void checkRecordPermission() throws SecurityException {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(new AudioPermission("record"));
}
}
/**
* Load properties from a file.
* <p>

View File

@ -40,10 +40,13 @@ import java.security.BasicPermission;
* @apiNote
* This permission cannot be used for controlling access to resources
* as the Security Manager is no longer supported.
* Consequently this class is deprecated and may be removed in a future release.
*
* @author Kara Kytle
* @since 1.3
* @deprecated There is no replacement for this class.
*/
@Deprecated(since="24", forRemoval=true)
public class AudioPermission extends BasicPermission {
/**

View File

@ -21,7 +21,6 @@
* questions.
*/
import javax.sound.sampled.AudioPermission;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.Line;
@ -35,18 +34,6 @@ import javax.sound.sampled.SourceDataLine;
*/
public class GetLine {
static boolean isSoundAccessDenied = false;
static {
SecurityManager securityManager = System.getSecurityManager();
if (securityManager != null) {
try {
securityManager.checkPermission(new AudioPermission("*"));
} catch (SecurityException e) {
isSoundAccessDenied = true;
}
}
}
static final int STATUS_PASSED = 0;
static final int STATUS_FAILED = 2;
static final int STATUS_TEMP = 95;
@ -80,9 +67,6 @@ public class GetLine {
}
try {
l = AudioSystem.getLine(infos[0]);
} catch(SecurityException lue) {
log.println("SecurityException");
return STATUS_PASSED;
} catch (LineUnavailableException e1) {
log.println("LUE");
return STATUS_PASSED;