Skip to content

Commit

Permalink
[JBWS-4424]:Add AccessController.doPrivileged to ServiceImpl.class.ge…
Browse files Browse the repository at this point in the history
…tClassLoader() to fix the security permission check failed issue
  • Loading branch information
jimma committed Aug 14, 2024
1 parent 8478916 commit fe1efd8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ protected <T> T createPort(QName portName, EndpointReferenceType epr, Class<T> s
ClassLoader origClassLoader = getContextClassLoader();
T port = null;
try {
setContextClassLoader(createDelegateClassLoader(origClassLoader, ServiceImpl.class.getClassLoader()));
setContextClassLoader(createDelegateClassLoader(origClassLoader, SecurityActions.getClassLoader(ServiceImpl.class));
port = super.createPort(portName, epr, serviceEndpointInterface, features);
} finally {
setContextClassLoader(origClassLoader);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,26 @@ public Object run()
});
}
}

static ClassLoader getClassLoader(Class clazz)
{
SecurityManager sm = System.getSecurityManager();
if (sm == null)
{
return clazz.getClassLoader();
}
else
{
return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
{
public ClassLoader run()
{
return clazz.getClassLoader();
}
});
}
}


/**
* Return the current value of the specified system property
Expand Down

0 comments on commit fe1efd8

Please sign in to comment.