Skip to content

Commit f1fbe1a

Browse files
authored
Merge pull request #383 from basil/acegi
`FlowExecution#getAuthentication2`
2 parents d6b6b80 + 7993673 commit f1fbe1a

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

src/main/java/org/jenkinsci/plugins/workflow/flow/FlowExecution.java

+20-3
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@
4747
import edu.umd.cs.findbugs.annotations.NonNull;
4848
import jenkins.model.Jenkins;
4949
import jenkins.model.queue.AsynchronousExecution;
50-
import org.acegisecurity.Authentication;
5150
import org.jenkinsci.plugins.workflow.steps.FlowInterruptedException;
5251
import org.kohsuke.accmod.Restricted;
5352
import org.kohsuke.accmod.restrictions.NoExternalUse;
53+
import org.springframework.security.core.Authentication;
5454

5555
/**
5656
* State of a currently executing workflow.
@@ -248,10 +248,27 @@ public boolean blocksRestart() {
248248
* Looks up authentication associated with this flow execution.
249249
* For example, if a flow is configured to be a trusted agent of a user, that would be set here.
250250
* A flow run triggered by a user manually might be associated with the runtime, or it might not.
251-
* @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
251+
* @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
252252
*/
253-
public abstract @NonNull Authentication getAuthentication();
253+
public /* abstract */ @NonNull Authentication getAuthentication2() {
254+
return Util.ifOverridden(
255+
() -> getAuthentication().toSpring(),
256+
org.acegisecurity.Authentication.class,
257+
getClass(),
258+
"getAuthentication");
259+
}
254260

261+
/**
262+
* @deprecated use {@link #getAuthentication2()}
263+
*/
264+
@Deprecated
265+
public /* abstract */ @NonNull org.acegisecurity.Authentication getAuthentication() {
266+
return Util.ifOverridden(
267+
() -> org.acegisecurity.Authentication.fromSpring(getAuthentication2()),
268+
Authentication.class,
269+
getClass(),
270+
"getAuthentication2");
271+
}
255272

256273
/** @see GraphLookupView#isActive(FlowNode)
257274
* @throws IllegalArgumentException If the input {@link FlowNode} does not belong to this execution

src/test/java/org/jenkinsci/plugins/workflow/log/LogStorageTestBase.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
import java.util.logging.Level;
5252
import jenkins.model.CauseOfInterruption;
5353
import jenkins.security.MasterToSlaveCallable;
54-
import org.acegisecurity.Authentication;
5554
import org.apache.commons.io.FileUtils;
5655
import org.apache.commons.io.output.NullOutputStream;
5756
import org.apache.commons.io.output.NullWriter;
@@ -68,6 +67,7 @@
6867
import org.junit.Test;
6968
import org.jvnet.hudson.test.JenkinsRule;
7069
import org.jvnet.hudson.test.LoggerRule;
70+
import org.springframework.security.core.Authentication;
7171

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

394394
@NonNull
395395
@Override
396-
public Authentication getAuthentication() {
396+
public Authentication getAuthentication2() {
397397
throw new UnsupportedOperationException();
398398
}
399399

0 commit comments

Comments
 (0)