Skip to content
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

FlowExecution#getAuthentication2 #383

Merged
merged 1 commit into from
Mar 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@
import edu.umd.cs.findbugs.annotations.NonNull;
import jenkins.model.Jenkins;
import jenkins.model.queue.AsynchronousExecution;
import org.acegisecurity.Authentication;
import org.jenkinsci.plugins.workflow.steps.FlowInterruptedException;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
import org.springframework.security.core.Authentication;

/**
* State of a currently executing workflow.
Expand Down Expand Up @@ -248,10 +248,27 @@
* Looks up authentication associated with this flow execution.
* For example, if a flow is configured to be a trusted agent of a user, that would be set here.
* A flow run triggered by a user manually might be associated with the runtime, or it might not.
* @return an authentication; {@link ACL#SYSTEM} as a fallback, or {@link Jenkins#ANONYMOUS} if the flow is supposed to be limited to a specific user but that user cannot now be looked up
* @return an authentication; {@link ACL#SYSTEM2} as a fallback, or {@link Jenkins#ANONYMOUS2} if the flow is supposed to be limited to a specific user but that user cannot now be looked up
*/
public abstract @NonNull Authentication getAuthentication();
public /* abstract */ @NonNull Authentication getAuthentication2() {
return Util.ifOverridden(
() -> getAuthentication().toSpring(),
org.acegisecurity.Authentication.class,
getClass(),
"getAuthentication");
}

/**
* @deprecated use {@link #getAuthentication2()}
*/
@Deprecated
public /* abstract */ @NonNull org.acegisecurity.Authentication getAuthentication() {
return Util.ifOverridden(
() -> org.acegisecurity.Authentication.fromSpring(getAuthentication2()),
Authentication.class,
getClass(),

Check warning on line 269 in src/main/java/org/jenkinsci/plugins/workflow/flow/FlowExecution.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 254-269 are not covered by tests
"getAuthentication2");
}

/** @see GraphLookupView#isActive(FlowNode)
* @throws IllegalArgumentException If the input {@link FlowNode} does not belong to this execution
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
import java.util.logging.Level;
import jenkins.model.CauseOfInterruption;
import jenkins.security.MasterToSlaveCallable;
import org.acegisecurity.Authentication;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.output.NullOutputStream;
import org.apache.commons.io.output.NullWriter;
Expand All @@ -68,6 +67,7 @@
import org.junit.Test;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.LoggerRule;
import org.springframework.security.core.Authentication;

/**
* Foundation for compliance tests of {@link LogStorage} implementations.
Expand Down Expand Up @@ -393,7 +393,7 @@ public FlowNode getNode(String id) {

@NonNull
@Override
public Authentication getAuthentication() {
public Authentication getAuthentication2() {
throw new UnsupportedOperationException();
}

Expand Down
Loading