6903638: Remove dependency on AuthPermission from SecurityConstants
Move two static fields from SecurityConstants to javax.security.auth.Subject Reviewed-by: mullan
This commit is contained in:
parent
4da1e67db3
commit
01a5fb5da5
@ -40,7 +40,6 @@ import java.security.PrivilegedExceptionAction;
|
|||||||
import java.security.PrivilegedActionException;
|
import java.security.PrivilegedActionException;
|
||||||
import java.security.ProtectionDomain;
|
import java.security.ProtectionDomain;
|
||||||
import sun.security.util.ResourcesMgr;
|
import sun.security.util.ResourcesMgr;
|
||||||
import sun.security.util.SecurityConstants;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p> A <code>Subject</code> represents a grouping of related information
|
* <p> A <code>Subject</code> represents a grouping of related information
|
||||||
@ -239,7 +238,7 @@ public final class Subject implements java.io.Serializable {
|
|||||||
public void setReadOnly() {
|
public void setReadOnly() {
|
||||||
java.lang.SecurityManager sm = System.getSecurityManager();
|
java.lang.SecurityManager sm = System.getSecurityManager();
|
||||||
if (sm != null) {
|
if (sm != null) {
|
||||||
sm.checkPermission(new AuthPermission("setReadOnly"));
|
sm.checkPermission(AuthPermissionHolder.SET_READ_ONLY_PERMISSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.readOnly = true;
|
this.readOnly = true;
|
||||||
@ -285,7 +284,7 @@ public final class Subject implements java.io.Serializable {
|
|||||||
|
|
||||||
java.lang.SecurityManager sm = System.getSecurityManager();
|
java.lang.SecurityManager sm = System.getSecurityManager();
|
||||||
if (sm != null) {
|
if (sm != null) {
|
||||||
sm.checkPermission(new AuthPermission("getSubject"));
|
sm.checkPermission(AuthPermissionHolder.GET_SUBJECT_PERMISSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (acc == null) {
|
if (acc == null) {
|
||||||
@ -343,7 +342,7 @@ public final class Subject implements java.io.Serializable {
|
|||||||
|
|
||||||
java.lang.SecurityManager sm = System.getSecurityManager();
|
java.lang.SecurityManager sm = System.getSecurityManager();
|
||||||
if (sm != null) {
|
if (sm != null) {
|
||||||
sm.checkPermission(SecurityConstants.DO_AS_PERMISSION);
|
sm.checkPermission(AuthPermissionHolder.DO_AS_PERMISSION);
|
||||||
}
|
}
|
||||||
if (action == null)
|
if (action == null)
|
||||||
throw new NullPointerException
|
throw new NullPointerException
|
||||||
@ -402,7 +401,7 @@ public final class Subject implements java.io.Serializable {
|
|||||||
|
|
||||||
java.lang.SecurityManager sm = System.getSecurityManager();
|
java.lang.SecurityManager sm = System.getSecurityManager();
|
||||||
if (sm != null) {
|
if (sm != null) {
|
||||||
sm.checkPermission(SecurityConstants.DO_AS_PERMISSION);
|
sm.checkPermission(AuthPermissionHolder.DO_AS_PERMISSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action == null)
|
if (action == null)
|
||||||
@ -456,7 +455,7 @@ public final class Subject implements java.io.Serializable {
|
|||||||
|
|
||||||
java.lang.SecurityManager sm = System.getSecurityManager();
|
java.lang.SecurityManager sm = System.getSecurityManager();
|
||||||
if (sm != null) {
|
if (sm != null) {
|
||||||
sm.checkPermission(SecurityConstants.DO_AS_PRIVILEGED_PERMISSION);
|
sm.checkPermission(AuthPermissionHolder.DO_AS_PRIVILEGED_PERMISSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action == null)
|
if (action == null)
|
||||||
@ -520,7 +519,7 @@ public final class Subject implements java.io.Serializable {
|
|||||||
|
|
||||||
java.lang.SecurityManager sm = System.getSecurityManager();
|
java.lang.SecurityManager sm = System.getSecurityManager();
|
||||||
if (sm != null) {
|
if (sm != null) {
|
||||||
sm.checkPermission(SecurityConstants.DO_AS_PRIVILEGED_PERMISSION);
|
sm.checkPermission(AuthPermissionHolder.DO_AS_PRIVILEGED_PERMISSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action == null)
|
if (action == null)
|
||||||
@ -1044,16 +1043,13 @@ public final class Subject implements java.io.Serializable {
|
|||||||
if (sm != null) {
|
if (sm != null) {
|
||||||
switch (which) {
|
switch (which) {
|
||||||
case Subject.PRINCIPAL_SET:
|
case Subject.PRINCIPAL_SET:
|
||||||
sm.checkPermission(new AuthPermission
|
sm.checkPermission(AuthPermissionHolder.MODIFY_PRINCIPALS_PERMISSION);
|
||||||
("modifyPrincipals"));
|
|
||||||
break;
|
break;
|
||||||
case Subject.PUB_CREDENTIAL_SET:
|
case Subject.PUB_CREDENTIAL_SET:
|
||||||
sm.checkPermission(new AuthPermission
|
sm.checkPermission(AuthPermissionHolder.MODIFY_PUBLIC_CREDENTIALS_PERMISSION);
|
||||||
("modifyPublicCredentials"));
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sm.checkPermission(new AuthPermission
|
sm.checkPermission(AuthPermissionHolder.MODIFY_PRIVATE_CREDENTIALS_PERMISSION);
|
||||||
("modifyPrivateCredentials"));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1073,16 +1069,13 @@ public final class Subject implements java.io.Serializable {
|
|||||||
if (sm != null) {
|
if (sm != null) {
|
||||||
switch (which) {
|
switch (which) {
|
||||||
case Subject.PRINCIPAL_SET:
|
case Subject.PRINCIPAL_SET:
|
||||||
sm.checkPermission
|
sm.checkPermission(AuthPermissionHolder.MODIFY_PRINCIPALS_PERMISSION);
|
||||||
(new AuthPermission("modifyPrincipals"));
|
|
||||||
break;
|
break;
|
||||||
case Subject.PUB_CREDENTIAL_SET:
|
case Subject.PUB_CREDENTIAL_SET:
|
||||||
sm.checkPermission
|
sm.checkPermission(AuthPermissionHolder.MODIFY_PUBLIC_CREDENTIALS_PERMISSION);
|
||||||
(new AuthPermission("modifyPublicCredentials"));
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sm.checkPermission
|
sm.checkPermission(AuthPermissionHolder.MODIFY_PRIVATE_CREDENTIALS_PERMISSION);
|
||||||
(new AuthPermission("modifyPrivateCredentials"));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1405,4 +1398,27 @@ public final class Subject implements java.io.Serializable {
|
|||||||
return set.add(o);
|
return set.add(o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class AuthPermissionHolder {
|
||||||
|
static final AuthPermission DO_AS_PERMISSION =
|
||||||
|
new AuthPermission("doAs");
|
||||||
|
|
||||||
|
static final AuthPermission DO_AS_PRIVILEGED_PERMISSION =
|
||||||
|
new AuthPermission("doAsPrivileged");
|
||||||
|
|
||||||
|
static final AuthPermission SET_READ_ONLY_PERMISSION =
|
||||||
|
new AuthPermission("setReadOnly");
|
||||||
|
|
||||||
|
static final AuthPermission GET_SUBJECT_PERMISSION =
|
||||||
|
new AuthPermission("getSubject");
|
||||||
|
|
||||||
|
static final AuthPermission MODIFY_PRINCIPALS_PERMISSION =
|
||||||
|
new AuthPermission("modifyPrincipals");
|
||||||
|
|
||||||
|
static final AuthPermission MODIFY_PUBLIC_CREDENTIALS_PERMISSION =
|
||||||
|
new AuthPermission("modifyPublicCredentials");
|
||||||
|
|
||||||
|
static final AuthPermission MODIFY_PRIVATE_CREDENTIALS_PERMISSION =
|
||||||
|
new AuthPermission("modifyPrivateCredentials");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,6 @@ import java.security.Permission;
|
|||||||
import java.security.BasicPermission;
|
import java.security.BasicPermission;
|
||||||
import java.security.SecurityPermission;
|
import java.security.SecurityPermission;
|
||||||
import java.security.AllPermission;
|
import java.security.AllPermission;
|
||||||
import javax.security.auth.AuthPermission;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Permission constants and string constants used to create permissions
|
* Permission constants and string constants used to create permissions
|
||||||
@ -259,12 +258,4 @@ public final class SecurityConstants {
|
|||||||
// java.lang.SecurityManager
|
// java.lang.SecurityManager
|
||||||
public static final SocketPermission LOCAL_LISTEN_PERMISSION =
|
public static final SocketPermission LOCAL_LISTEN_PERMISSION =
|
||||||
new SocketPermission("localhost:1024-", SOCKET_LISTEN_ACTION);
|
new SocketPermission("localhost:1024-", SOCKET_LISTEN_ACTION);
|
||||||
|
|
||||||
// javax.security.auth.Subject
|
|
||||||
public static final AuthPermission DO_AS_PERMISSION =
|
|
||||||
new AuthPermission("doAs");
|
|
||||||
|
|
||||||
// javax.security.auth.Subject
|
|
||||||
public static final AuthPermission DO_AS_PRIVILEGED_PERMISSION =
|
|
||||||
new AuthPermission("doAsPrivileged");
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user