Skip to content

Commit

Permalink
Migrate from Acegi compatibility layer to Spring Security (#1026)
Browse files Browse the repository at this point in the history
  • Loading branch information
basil authored Dec 21, 2024
1 parent bcb70f1 commit 40112c5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
15 changes: 7 additions & 8 deletions src/main/java/hudson/plugins/ec2/EC2Cloud.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
import com.cloudbees.plugins.credentials.common.AbstractIdCredentialsListBoxModel;
import com.cloudbees.plugins.credentials.common.StandardListBoxModel;
import com.cloudbees.plugins.credentials.domains.Domain;
import com.cloudbees.plugins.credentials.domains.DomainRequirement;
import com.google.common.annotations.VisibleForTesting;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
Expand Down Expand Up @@ -1127,8 +1126,8 @@ private static AmazonWebServicesCredentials getCredentials(@CheckForNull String
return null;
}
return CredentialsMatchers.firstOrNull(
CredentialsProvider.lookupCredentials(
AmazonWebServicesCredentials.class, Jenkins.get(), ACL.SYSTEM, Collections.emptyList()),
CredentialsProvider.lookupCredentialsInItemGroup(
AmazonWebServicesCredentials.class, Jenkins.get(), ACL.SYSTEM2, Collections.emptyList()),
CredentialsMatchers.withId(credentialsId));
}

Expand Down Expand Up @@ -1281,16 +1280,16 @@ public ListBoxModel doFillSshKeysCredentialsIdItems(
if (Jenkins.get().hasPermission(Jenkins.ADMINISTER)) {
result = result.includeEmptyValue()
.includeMatchingAs(
Jenkins.getAuthentication(),
Jenkins.getAuthentication2(),
context,
SSHUserPrivateKey.class,
Collections.<DomainRequirement>emptyList(),
Collections.emptyList(),
CredentialsMatchers.always())
.includeMatchingAs(
ACL.SYSTEM,
ACL.SYSTEM2,
context,
SSHUserPrivateKey.class,
Collections.<DomainRequirement>emptyList(),
Collections.emptyList(),
CredentialsMatchers.always())
.includeCurrentValue(sshKeysCredentialsId);
}
Expand Down Expand Up @@ -1479,7 +1478,7 @@ public ListBoxModel doFillCredentialsIdItems(@AncestorInPath ItemGroup context)
return new StandardListBoxModel()
.includeEmptyValue()
.includeMatchingAs(
ACL.SYSTEM,
ACL.SYSTEM2,
context,
AmazonWebServicesCredentials.class,
Collections.emptyList(),
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/hudson/plugins/ec2/EC2RetentionStrategy.java
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ private boolean itemsInQueueForThisSlave(EC2Computer c) {
return false;
}
final Label selfLabel = selfNode.getSelfLabel();
Queue.Item[] items = Jenkins.getInstance().getQueue().getItems();
Queue.Item[] items = Jenkins.get().getQueue().getItems();
for (Queue.Item item : items) {
final Label assignedLabel = item.getAssignedLabel();
if (assignedLabel == selfLabel) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@
import java.util.stream.Collectors;
import jenkins.model.Jenkins;
import jenkins.util.NonLocalizable;
import org.acegisecurity.Authentication;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.LoggerRule;
import org.springframework.security.core.Authentication;

public class EC2RetentionStrategyTest {

Expand Down Expand Up @@ -140,7 +140,7 @@ public String getShortDescription() {
public ACL getACL() {
return new ACL() {
@Override
public boolean hasPermission(@NonNull Authentication a, @NonNull Permission permission) {
public boolean hasPermission2(@NonNull Authentication a, @NonNull Permission permission) {
return true;
}
};
Expand Down

0 comments on commit 40112c5

Please sign in to comment.