Skip to content

Commit

Permalink
Queue.Item.authenticate honors QueueItemAuthenticatorProvider; Tasks.…
Browse files Browse the repository at this point in the history
…getAuthenticationOf should as well (#2880)

* Queue.Item.authenticate honors QueueItemAuthenticatorProvider; Tasks.getAuthenticationOf should as well.

* @oleg-nenashev suggested adding some Javadoc to QueueItemAuthenticatorConfiguration.getAuthenticators.
  • Loading branch information
jglick authored and oleg-nenashev committed May 19, 2017
1 parent 915543d commit 8199ec5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
6 changes: 2 additions & 4 deletions core/src/main/java/hudson/model/queue/Tasks.java
Expand Up @@ -34,9 +34,7 @@
import java.util.Collections;
import javax.annotation.Nonnull;
import jenkins.security.QueueItemAuthenticator;
import jenkins.security.QueueItemAuthenticatorConfiguration;

import static hudson.model.queue.Executables.getParentOf;
import jenkins.security.QueueItemAuthenticatorProvider;

/**
* Convenience methods around {@link Task} and {@link SubTask}.
Expand Down Expand Up @@ -136,7 +134,7 @@ public static Authentication getDefaultAuthenticationOf(Task t, Item item) {
* @since 1.560
*/
public static @Nonnull Authentication getAuthenticationOf(@Nonnull Task t) {
for (QueueItemAuthenticator qia : QueueItemAuthenticatorConfiguration.get().getAuthenticators()) {
for (QueueItemAuthenticator qia : QueueItemAuthenticatorProvider.authenticators()) {
Authentication a = qia.authenticate(t);
if (a != null) {
return a;
Expand Down
Expand Up @@ -9,6 +9,7 @@
import hudson.model.Queue;
import hudson.model.Queue.Item;
import hudson.model.Queue.Task;
import hudson.model.queue.Tasks;
import java.util.Calendar;
import java.util.Collections;
import javax.annotation.CheckForNull;
Expand All @@ -20,8 +21,9 @@
* @author Kohsuke Kawaguchi
* @since 1.520
* @see QueueItemAuthenticatorConfiguration
* @see QueueItemAuthenticatorProvider
* @see Item#authenticate()
* @see Task#getDefaultAuthentication()
* @see Tasks#getAuthenticationOf
*/
public abstract class QueueItemAuthenticator extends AbstractDescribableImpl<QueueItemAuthenticator> implements ExtensionPoint {
/**
Expand Down
@@ -1,6 +1,7 @@
package jenkins.security;

import hudson.Extension;
import hudson.model.queue.Tasks;
import hudson.util.DescribableList;
import jenkins.model.GlobalConfiguration;
import jenkins.model.GlobalConfigurationCategory;
Expand Down Expand Up @@ -38,6 +39,14 @@ public GlobalConfigurationCategory getCategory() {
return GlobalConfigurationCategory.get(GlobalConfigurationCategory.Security.class);
}

/**
* Provides all user-configured authenticators.
* Note that if you are looking to determine all <em>effective</em> authenticators,
* including any potentially supplied by plugins rather than user configuration,
* you should rather call {@link QueueItemAuthenticatorProvider#authenticators};
* or if you are looking for the authentication of an actual project, build, etc., use
* {@link hudson.model.Queue.Item#authenticate} or {@link Tasks#getAuthenticationOf}.
*/
public DescribableList<QueueItemAuthenticator, QueueItemAuthenticatorDescriptor> getAuthenticators() {
return authenticators;
}
Expand Down

0 comments on commit 8199ec5

Please sign in to comment.