提交 8199ec5a 编写于 作者: J Jesse Glick 提交者: Oleg Nenashev

Queue.Item.authenticate honors QueueItemAuthenticatorProvider;...

Queue.Item.authenticate honors QueueItemAuthenticatorProvider; Tasks.getAuthenticationOf should as well (#2880)

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

* @oleg-nenashev suggested adding some Javadoc to QueueItemAuthenticatorConfiguration.getAuthenticators.
上级 915543dc
......@@ -34,9 +34,7 @@ import java.util.Collection;
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}.
......@@ -136,7 +134,7 @@ public class Tasks {
* @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;
......
......@@ -9,6 +9,7 @@ import hudson.model.CauseAction;
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;
......@@ -20,8 +21,9 @@ import org.acegisecurity.Authentication;
* @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 {
/**
......
package jenkins.security;
import hudson.Extension;
import hudson.model.queue.Tasks;
import hudson.util.DescribableList;
import jenkins.model.GlobalConfiguration;
import jenkins.model.GlobalConfigurationCategory;
......@@ -38,6 +39,14 @@ public class QueueItemAuthenticatorConfiguration extends GlobalConfiguration {
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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册