Skip to content

Commit

Permalink
Replace deprecated Acegi security
Browse files Browse the repository at this point in the history
  • Loading branch information
offa committed Dec 23, 2022
1 parent 61f5f86 commit dea9b3e
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/main/java/jenkins/scm/api/SCMEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import hudson.model.Run;
import hudson.model.TaskListener;
import hudson.security.ACL;
import hudson.security.ACLContext;
import hudson.util.ClassLoaderSanityThreadFactory;
import hudson.util.DaemonThreadFactory;
import hudson.util.NamingThreadFactory;
Expand All @@ -47,8 +48,6 @@
import javax.servlet.http.HttpServletRequest;
import jenkins.security.ImpersonatingScheduledExecutorService;
import jenkins.util.SystemProperties;
import org.acegisecurity.context.SecurityContext;
import org.acegisecurity.context.SecurityContextHolder;
import org.apache.commons.lang.StringUtils;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
Expand Down Expand Up @@ -541,17 +540,16 @@ public void run() {
event.getClass(), event.getTimestamp(), oldName)
);
for (final SCMEventListener l : ExtensionList.lookup(SCMEventListener.class)) {
SecurityContext context = ACL.impersonate(ACL.SYSTEM);
try {
fire(l, event);
} catch (LinkageError e) {
log(l, e);
} catch (Error e) {
throw e;
} catch (Throwable e) {
log(l, e);
} finally {
SecurityContextHolder.setContext(context);
try (ACLContext ctx = ACL.as2(ACL.SYSTEM2)) {
try {
fire(l, event);
} catch (LinkageError e) {
log(l, e);
} catch (Error e) {
throw e;
} catch (Throwable e) {
log(l, e);
}
}
}
} finally {
Expand Down

0 comments on commit dea9b3e

Please sign in to comment.