-
Notifications
You must be signed in to change notification settings - Fork 738
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
Update doPrivilegedWithCombinerHelper function #20430
Conversation
4f2a353
to
05d9970
Compare
04afd31
to
5c436bf
Compare
@keithc-ca please help to review |
Hello, the failed case in #19499 is https://github.com/ibmruntimes/openj9-openjdk-jdk23/blob/openj9/test/jdk/javax/security/auth/Subject/Compat.java#L101. There is a personal build that pass
|
AccessControlContext parentContext = getContextHelper(context == null); | ||
DomainCombiner domaincombiner = parentContext.getCombiner(); | ||
|
||
return new AccessControlContext(pdArray, domaincombiner, parentContext, context, getNewAuthorizedState(context, domain)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return new AccessControlContext(pdArray, domaincombiner, parentContext, context, getNewAuthorizedState(context, domain)); | |
return new AccessControlContext(pdArray, parentContext, context, getNewAuthorizedState(context, domain)); |
domaincombiner = parentContext.getCombiner()
can be invoked within the constructor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It still passes both parentContext.getCombiner()
and parentContext
, only parentContext
is needed.
In addition, pls use tabs instead of spaces to be consistent with the existing codebase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
55d5f54
to
7bafa71
Compare
@@ -351,6 +350,36 @@ public AccessControlContext(ProtectionDomain[] fromContext) { | |||
this.containPrivilegedContext = true; | |||
} | |||
|
|||
AccessControlContext(ProtectionDomain[] pdArray, AccessControlContext parent, AccessControlContext acc, int authorizeState) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AccessControlContext(ProtectionDomain[] pdArray, AccessControlContext parent, AccessControlContext acc, int authorizeState) { | |
AccessControlContext(ProtectionDomain[] pdArray, AccessControlContext parentAcc, AccessControlContext context, int authorizeState) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
case STATE_AUTHORIZED: | ||
if (null != acc) { | ||
// when parent combiner is not null, use parent combiner to combine the current context | ||
if (parent.getCombiner() != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parent
could be null
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
} | ||
this.doPrivilegedAcc = acc; | ||
this.authorizeState = authorizeState; | ||
this.containPrivilegedContext = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can AccessControlContext(AccessControlContext acc, ProtectionDomain[] context, int authorizeState)
invoke this constructor to avoid code duplication?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be in a new constructor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jason makes a good suggstion: the two constructors above can use the new one:
AccessControlContext(ProtectionDomain[] context, int authorizeState) {
this(context, null, null, authorizeState);
}
AccessControlContext(AccessControlContext acc, ProtectionDomain[] context, int authorizeState) {
this(context, null, acc, authorizeState);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
/*[IF JAVA_SPEC_VERSION >= 24]*/ | ||
/*[MSG "K002e", "checking permissions is not supported"]*/ | ||
throw new AccessControlException(Msg.getString("K002e")); //$NON-NLS-1$ | ||
/*[ELSE] JAVA_SPEC_VERSION >= 24 */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please not remove this and other recent merged changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
29e2976
to
6d202c9
Compare
} else { | ||
this.domainCombiner = parentAcc.domainCombiner; | ||
this.context = pdArray; | ||
this.nextStackAcc = parentAcc; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changed the AccessControlContext(AccessControlContext acc, ProtectionDomain[] context, int authorizeState)
behaviour.
To avoid the uncertainty of existing AccessControlContext()
constructors which is being disabled permanently for JDK24+, I revert the previous suggestion. Pls separate this new constructor from others.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
0b44640
to
520741c
Compare
Please verify that the updated change still passes #19499 and the compliance tests. |
jcl/src/java.base/share/classes/java/security/AccessController.java
Outdated
Show resolved
Hide resolved
} | ||
this.doPrivilegedAcc = acc; | ||
this.authorizeState = authorizeState; | ||
this.containPrivilegedContext = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jason makes a good suggstion: the two constructors above can use the new one:
AccessControlContext(ProtectionDomain[] context, int authorizeState) {
this(context, null, null, authorizeState);
}
AccessControlContext(AccessControlContext acc, ProtectionDomain[] context, int authorizeState) {
this(context, null, acc, authorizeState);
}
jcl/src/java.base/share/classes/java/security/AccessControlContext.java
Outdated
Show resolved
Hide resolved
jcl/src/java.base/share/classes/java/security/AccessControlContext.java
Outdated
Show resolved
Hide resolved
jcl/src/java.base/share/classes/java/security/AccessControlContext.java
Outdated
Show resolved
Hide resolved
ad23095
to
d51c66b
Compare
a992864
to
9dd994d
Compare
jcl/src/java.base/share/classes/java/security/AccessControlContext.java
Outdated
Show resolved
Hide resolved
jcl/src/java.base/share/classes/java/security/AccessController.java
Outdated
Show resolved
Hide resolved
ba0a69c
to
041311e
Compare
jcl/src/java.base/share/classes/java/security/AccessControlContext.java
Outdated
Show resolved
Hide resolved
jcl/src/java.base/share/classes/java/security/AccessControlContext.java
Outdated
Show resolved
Hide resolved
Please squash in preparation for testing. |
|
When we try to invoke doPrivilegedWithCombiner function to perform a privileged action under an existing context environment, we are used to construct a new context but ignore the parent context. We should take consideration of a combination of the current and parent context, rather than just choose either the current or the parent. This patch solves a failed case in issue eclipse-openj9#19499. Issue: eclipse-openj9#19499 Signed-off-by: Jinhang Zhang <[email protected]>
done |
Jenkins test sanity amac jdk23 |
When we try to invoke doPrivilegedWithCombiner function to
perform a privileged action under an existing context
environment, we are used to construct a new context but ignore
the parent context.
We should take consideration of a combination of the current
and parent context, rather than just choose either the current
or the parent.
This patch solves the failed case in issue #19499.