Skip to content

Commit e88c5af

Browse files
authored
Merge pull request #251 from basil/refresh
Migrate from Acegi to Spring Security
2 parents cc7d47f + 84bdbdd commit e88c5af

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

src/main/java/hudson/plugins/im/AuthenticationHolder.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package hudson.plugins.im;
22

3-
import org.acegisecurity.Authentication;
3+
import org.springframework.security.core.Authentication;
44

55
/**
66
* Just a holder to return a (possibly cached) {@link Authentication}.

src/main/java/hudson/plugins/im/IMConnectionProvider.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@
99
import java.util.logging.Logger;
1010

1111
import jenkins.model.Jenkins;
12-
import org.acegisecurity.Authentication;
13-
import org.acegisecurity.userdetails.UsernameNotFoundException;
14-
//import org.springframework.security.core.userdetails.UsernameNotFoundException;
12+
import org.springframework.security.core.Authentication;
13+
import org.springframework.security.core.userdetails.UsernameNotFoundException;
1514

1615
/**
1716
* Abstract implementation of a provider of {@link IMConnection}s.
@@ -141,7 +140,7 @@ public Authentication getAuthentication() {
141140

142141
try {
143142
User u = User.get(descriptor.getHudsonUserName());
144-
return u.impersonate();
143+
return u.impersonate2();
145144
} catch (UsernameNotFoundException ue) {
146145
if (descriptor.getHudsonUserName().isBlank()) {
147146
throw new UsernameNotFoundException(

src/main/java/hudson/plugins/im/bot/Bot.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
import jenkins.model.Jenkins;
2828
import jenkins.security.NotReallyRoleSensitiveCallable;
29-
import org.acegisecurity.userdetails.UsernameNotFoundException;
29+
import org.springframework.security.core.userdetails.UsernameNotFoundException;
3030

3131
/**
3232
* Instant messaging bot.
@@ -164,7 +164,7 @@ public void onMessage(final IMMessage msg) {
164164
if (command != null) {
165165
if (isAuthenticationNeeded()) {
166166
try {
167-
ACL.impersonate(this.authentication.getAuthentication(), new NotReallyRoleSensitiveCallable<Void, IMException>() {
167+
ACL.impersonate2(this.authentication.getAuthentication(), new NotReallyRoleSensitiveCallable<Void, IMException>() {
168168
private static final long serialVersionUID = 1L;
169169

170170
@Override

src/main/java/hudson/plugins/im/bot/BuildCommand.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ private String checkPermission(Sender sender, AbstractProject<?, ?> project) {
247247
if ( senderUser != null ) {
248248
// This check is hopefully equivalent to legacy one defined above,
249249
// project.hasPermission(Item.BUILD), but for an arbitrary username
250-
if (Jenkins.getInstance().getAuthorizationStrategy().getACL(project).hasPermission(senderUser.impersonate(), Item.BUILD)) {
250+
if (Jenkins.getInstance().getAuthorizationStrategy().getACL(project).hasPermission2(senderUser.impersonate2(), Item.BUILD)) {
251251
System.err.println("IM BuildCommand authorized Jenkins user '" +
252252
senderUser.getId() + "' (IM ID '" + sender.getNickname() +
253253
"' / '" + sender.getId() + "') to build '" + project.getName() +

0 commit comments

Comments
 (0)