-
Notifications
You must be signed in to change notification settings - Fork 104
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
[JENKINS-34426] Fix to handle SECURITY-243 #34
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ | |
package hudson.plugins.active_directory; | ||
|
||
import java.io.IOException; | ||
import java.lang.reflect.InvocationTargetException; | ||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.HashSet; | ||
|
@@ -177,6 +178,19 @@ public static long getSerialVersionUID() { | |
* Gets the corresponding {@link hudson.model.User} object. | ||
*/ | ||
public hudson.model.User getJenkinsUser() { | ||
try { // TODO 1.651.2+ remove reflection | ||
return (hudson.model.User) hudson.model.User.class.getMethod("getById", String.class, boolean.class).invoke(null, getUsername(), true); | ||
} catch (InvocationTargetException e) { | ||
if (e.getCause() instanceof RuntimeException) { | ||
throw (RuntimeException)e.getCause(); | ||
} | ||
// Only RuntimeException is expected | ||
LOGGER.log(Level.WARNING, String.format("There was a problem obtaining the Jenkins user %s by Id", getUsername()), e); | ||
} catch (NoSuchMethodException e) { | ||
// fine, older baseline | ||
} catch (Exception e) { // unexpected | ||
LOGGER.log(Level.WARNING, String.format("There was a problem obtaining the Jenkins user %s by Id", getUsername()), e); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @andresrc Are you sure it is necessary? |
||
return hudson.model.User.get(getUsername()); | ||
} | ||
|
||
|
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 does not look thread safe to me. cacheMiss is a class level field...
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.
Yes I asked for a method scoped field