Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ public SecurityCookieImpl preInvoke(EJBRequestData request) throws EJBAccessDeni
EJBSecurityContext ejbSecurityContext = new EJBSecurityContext(subjectManager.getInvocationSubject(), subjectManager.getCallerSubject());
syncToOSThread(ejbSecurityContext);
SecurityCookieImpl securityCookie = new SecurityCookieImpl(originalInvokedSubject, originalCallerSubject, subjectManager.getInvocationSubject(), subjectToAuthorize);
securityCookie.setSyncToOSThreadToken(ejbSecurityContext.getSyncToOSThreadToken());
return securityCookie;
}

Expand Down Expand Up @@ -262,8 +263,7 @@ public void postInvoke(EJBRequestData request, SecurityCookieImpl preInvokeResul
}
}
try {
EJBSecurityContext ejbSecurityContext = new EJBSecurityContext(subjectManager.getInvocationSubject(), subjectManager.getCallerSubject());
resetSyncToOSThread(ejbSecurityContext);
resetSyncToOSThread(securityCookie);

} catch (ThreadIdentityException e) {
throw new EJBAccessDeniedException(TraceNLS.getFormattedMessage(this.getClass(),
Expand Down Expand Up @@ -840,8 +840,8 @@ private void syncToOSThread(EJBSecurityContext ejbSecurityContext) throws EJBAcc
* MUST NOT BE NULL.
* @throws ThreadIdentityException
*/
private void resetSyncToOSThread(EJBSecurityContext ejbSecurityContext) throws ThreadIdentityException {
Object token = ejbSecurityContext.getSyncToOSThreadToken();
private void resetSyncToOSThread(SecurityCookieImpl securityCookie) throws ThreadIdentityException {
Object token = securityCookie.getSyncToOSThreadToken();
if (token != null) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Resetting thread identity for EJB application");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2012 IBM Corporation and others.
* Copyright (c) 2012, 2025 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
Expand All @@ -22,6 +22,7 @@ public class SecurityCookieImpl {
private final Subject receivedSubject;
private final Subject adjustedInvokedSubject;
private final Subject adjustedReceivedSubject;
private Object syncToOSThreadToken;

SecurityCookieImpl(Subject invokedSubject, Subject receivedSubject) {
this.invokedSubject = this.adjustedInvokedSubject =invokedSubject;
Expand Down Expand Up @@ -50,4 +51,12 @@ public Subject getAdjustedInvokedSubject() {
public Subject getAdjustedReceivedSubject() {
return adjustedReceivedSubject;
}

public Object getSyncToOSThreadToken() {
return syncToOSThreadToken;
}

public void setSyncToOSThreadToken(Object token) {
this.syncToOSThreadToken = token;
}
}