Skip to content

Commit 891b3a9

Browse files
authored
Merge pull request #70 from i386/remove-fire-authenticated-hack
Remove the SecurityListener.fireAuthenticated reflection hack
2 parents 4bd1519 + a0a798a commit 891b3a9

File tree

1 file changed

+2
-23
lines changed

1 file changed

+2
-23
lines changed

src/main/java/org/jenkinsci/plugins/GithubSecurityRealm.java

+2-23
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ of this software and associated documentation files (the "Software"), to deal
4343
import hudson.tasks.Mailer;
4444
import hudson.util.Secret;
4545
import jenkins.model.Jenkins;
46+
import jenkins.security.SecurityListener;
4647
import org.acegisecurity.Authentication;
4748
import org.acegisecurity.AuthenticationException;
4849
import org.acegisecurity.AuthenticationManager;
@@ -79,14 +80,11 @@ of this software and associated documentation files (the "Software"), to deal
7980
import javax.annotation.Nonnull;
8081
import javax.annotation.Nullable;
8182
import java.io.IOException;
82-
import java.lang.reflect.InvocationTargetException;
83-
import java.lang.reflect.Method;
8483
import java.net.InetSocketAddress;
8584
import java.net.Proxy;
8685
import java.util.Arrays;
8786
import java.util.HashSet;
8887
import java.util.Set;
89-
import java.util.logging.Level;
9088
import java.util.logging.Logger;
9189

9290
/**
@@ -392,7 +390,7 @@ public HttpResponse doFinishLogin(StaplerRequest request)
392390
}
393391
}
394392

395-
fireAuthenticated(new GithubOAuthUserDetails(self.getLogin(), auth.getAuthorities()));
393+
SecurityListener.fireAuthenticated(new GithubOAuthUserDetails(self.getLogin(), auth.getAuthorities()));
396394
} else {
397395
Log.info("Github did not return an access token.");
398396
}
@@ -429,25 +427,6 @@ private String getAccessToken(@Nonnull String code) throws IOException {
429427
return null;
430428
}
431429

432-
/**
433-
* Calls {@code SecurityListener.fireAuthenticated()} but through reflection to avoid
434-
* hard dependency on non-LTS core version.
435-
* TODO delete in 1.569+
436-
*/
437-
private void fireAuthenticated(UserDetails details) {
438-
try {
439-
Class<?> c = Class.forName("jenkins.security.SecurityListener");
440-
Method m = c.getMethod("fireAuthenticated", UserDetails.class);
441-
m.invoke(null,details);
442-
} catch (ClassNotFoundException | NoSuchMethodException e) {
443-
// running with old core
444-
} catch (IllegalAccessException e) {
445-
throw (Error)new IllegalAccessError(e.getMessage()).initCause(e);
446-
} catch (InvocationTargetException e) {
447-
LOGGER.log(Level.WARNING, "Failed to invoke fireAuthenticated", e);
448-
}
449-
}
450-
451430
/**
452431
* Returns the proxy to be used when connecting to the given URI.
453432
*/

0 commit comments

Comments
 (0)