当前位置: 首页>>代码示例>>Java>>正文


Java Item.hasPermission方法代码示例

本文整理汇总了Java中hudson.model.Item.hasPermission方法的典型用法代码示例。如果您正苦于以下问题:Java Item.hasPermission方法的具体用法?Java Item.hasPermission怎么用?Java Item.hasPermission使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在hudson.model.Item的用法示例。


在下文中一共展示了Item.hasPermission方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doFillMirrorgateCredentialsIdItems

import hudson.model.Item; //导入方法依赖的package包/类
public ListBoxModel doFillMirrorgateCredentialsIdItems(
        @AncestorInPath Item item,
        @QueryParameter("mirrorgateCredentialsId") String credentialsId) {

    StandardListBoxModel result = new StandardListBoxModel();
    if (item == null) {
        if (!Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER)) {
            return result.includeCurrentValue(credentialsId);
        }
    } else if (!item.hasPermission(Item.EXTENDED_READ)
            && !item.hasPermission(CredentialsProvider.USE_ITEM)) {
        return result.includeCurrentValue(credentialsId);
    }
    return result
            .includeEmptyValue()
            .includeAs(ACL.SYSTEM, item, StandardUsernamePasswordCredentials.class);
}
 
开发者ID:BBVA,项目名称:mirrorgate-jenkins-builds-collector,代码行数:18,代码来源:MirrorGatePublisher.java

示例2: doCheckMirrorgateCredentialsId

import hudson.model.Item; //导入方法依赖的package包/类
public FormValidation doCheckMirrorgateCredentialsId(
        @AncestorInPath Item item,
        @QueryParameter("mirrorgateCredentialsId") String credentialsId) {

    if (item == null) {
        if (!Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER)) {
            return FormValidation.ok();
        }
    } else if (!item.hasPermission(Item.EXTENDED_READ)
            && !item.hasPermission(CredentialsProvider.USE_ITEM)) {
        return FormValidation.ok();
    }
    if (StringUtils.isBlank(credentialsId)) {
        return FormValidation.ok();
    }
    if (credentialsId.startsWith("${") && credentialsId.endsWith("}")) {
        return FormValidation.warning(
                "Cannot validate expression based credentials");
    }
    return FormValidation.ok();
}
 
开发者ID:BBVA,项目名称:mirrorgate-jenkins-builds-collector,代码行数:22,代码来源:MirrorGatePublisher.java

示例3: doFillCredentialsIdItems

import hudson.model.Item; //导入方法依赖的package包/类
public ListBoxModel doFillCredentialsIdItems(
    @AncestorInPath Item context,
    @QueryParameter String remote,
    @QueryParameter String credentialsId) {
  if (context == null && !Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER)
      || context != null && !context.hasPermission(Item.EXTENDED_READ)) {
    return new StandardListBoxModel().includeCurrentValue(credentialsId);
  }
  return new StandardListBoxModel()
      .includeEmptyValue()
      .includeMatchingAs(
          context instanceof Queue.Task
              ? Tasks.getAuthenticationOf((Queue.Task) context)
              : ACL.SYSTEM,
          context,
          StandardUsernameCredentials.class,
          URIRequirementBuilder.fromUri(remote).build(),
          GitClient.CREDENTIALS_MATCHER)
      .includeCurrentValue(credentialsId);
}
 
开发者ID:GerritForge,项目名称:gerrit-plugin,代码行数:21,代码来源:GerritSCMSource.java

示例4: doFillCredentialsIdItems

import hudson.model.Item; //导入方法依赖的package包/类
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Item item) {
    if (item == null && !Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER) ||
        item != null && !item.hasPermission(Item.EXTENDED_READ)) {
        return new StandardListBoxModel();
    }
    // TODO may also need to specify a specific authentication and domain requirements
    return new StandardListBoxModel()
            .withEmptySelection()
            .withMatching(AuthenticationTokens.matcher(DockerRegistryToken.class),
                    CredentialsProvider.lookupCredentials(
                            StandardCredentials.class,
                            item,
                            null,
                            Collections.<DomainRequirement>emptyList()
                    )
            );
}
 
开发者ID:jenkinsci,项目名称:docker-commons-plugin,代码行数:18,代码来源:DockerRegistryEndpoint.java

示例5: doFillCredentialItems

import hudson.model.Item; //导入方法依赖的package包/类
@SuppressFBWarnings(value="NP_NULL_PARAM_DEREF", justification="pending https://github.com/jenkinsci/credentials-plugin/pull/68")
static public ListBoxModel doFillCredentialItems(Item project, String credentialsId) {

	if(project == null && !Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER) ||
			project != null && !project.hasPermission(Item.EXTENDED_READ)) {
		return new StandardListBoxModel().includeCurrentValue(credentialsId);
	}

	return new StandardListBoxModel()
			.includeEmptyValue()
			.includeMatchingAs(
					project instanceof Queue.Task
							? Tasks.getAuthenticationOf((Queue.Task) project)
							: ACL.SYSTEM,
					project,
					P4BaseCredentials.class,
					Collections.<DomainRequirement>emptyList(),
					CredentialsMatchers.instanceOf(P4BaseCredentials.class));
}
 
开发者ID:p4paul,项目名称:p4-jenkins,代码行数:20,代码来源:P4CredentialsImpl.java

示例6: doFillCredentialIdItems

import hudson.model.Item; //导入方法依赖的package包/类
public AbstractIdCredentialsListBoxModel<?, ?> doFillCredentialIdItems(
        @AncestorInPath Item owner) {
    if (owner == null || !owner.hasPermission(Item.CONFIGURE)) {
        return new AWSCredentialsListBoxModel();
    }

    List<AmazonWebServicesCredentials>
            creds =
            CredentialsProvider
                    .lookupCredentials(AmazonWebServicesCredentials.class, owner, ACL.SYSTEM,
                            Collections.<DomainRequirement>emptyList());

    return new AWSCredentialsListBoxModel()
            .withEmptySelection()
            .withAll(creds);
}
 
开发者ID:ingenieux,项目名称:awseb-deployment-plugin,代码行数:17,代码来源:AWSEBDeploymentBuilder.java

示例7: doFillCredentialsIdItems

import hudson.model.Item; //导入方法依赖的package包/类
@Restricted(NoExternalUse.class)
@SuppressWarnings("unused") // stapler form binding
public ListBoxModel doFillCredentialsIdItems(@CheckForNull @AncestorInPath Item context,
                                             @QueryParameter String serverUrl,
                                             @QueryParameter String credentialsId) {
    StandardListBoxModel result = new StandardListBoxModel();
    if (context == null) {
        if (!Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER)) {
            // must have admin if you want the list without a context
            result.includeCurrentValue(credentialsId);
            return result;
        }
    } else {
        if (!context.hasPermission(Item.EXTENDED_READ)
                && !context.hasPermission(CredentialsProvider.USE_ITEM)) {
            // must be able to read the configuration or use the item credentials if you want the list
            result.includeCurrentValue(credentialsId);
            return result;
        }
    }
    result.add(Messages.SSHCheckoutTrait_useAgentKey(), "");
    result.includeMatchingAs(
            context instanceof Queue.Task ?
                    Tasks.getDefaultAuthenticationOf((Queue.Task) context)
                    : ACL.SYSTEM,
            context,
            StandardUsernameCredentials.class,
            URIRequirementBuilder.fromUri(serverUrl).build(),
            CredentialsMatchers.instanceOf(SSHUserPrivateKey.class)
    );
    return result;
}
 
开发者ID:jenkinsci,项目名称:gitea-plugin,代码行数:33,代码来源:SSHCheckoutTrait.java

示例8: doCheckCredentialsId

import hudson.model.Item; //导入方法依赖的package包/类
/**
 * Validation for checkout credentials.
 *
 * @param context   the context.
 * @param serverUrl the server url.
 * @param value     the current selection.
 * @return the validation results
 */
@Restricted(NoExternalUse.class)
@SuppressWarnings("unused") // stapler form binding
public FormValidation doCheckCredentialsId(@CheckForNull @AncestorInPath Item context,
                                           @QueryParameter String serverUrl,
                                           @QueryParameter String value) {
    if (context == null
            ? !Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER)
            : !context.hasPermission(Item.EXTENDED_READ)) {
        return FormValidation.ok();
    }
    if (StringUtils.isBlank(value)) {
        // use agent key
        return FormValidation.ok();
    }
    if (CredentialsMatchers.firstOrNull(CredentialsProvider
                    .lookupCredentials(SSHUserPrivateKey.class, context, context instanceof Queue.Task
                            ? Tasks.getDefaultAuthenticationOf((Queue.Task) context)
                            : ACL.SYSTEM, URIRequirementBuilder.fromUri(serverUrl).build()),
            CredentialsMatchers.withId(value)) != null) {
        return FormValidation.ok();
    }
    if (CredentialsMatchers.firstOrNull(CredentialsProvider
                    .lookupCredentials(StandardUsernameCredentials.class, context, context instanceof Queue.Task
                            ? Tasks.getDefaultAuthenticationOf((Queue.Task) context)
                            : ACL.SYSTEM, URIRequirementBuilder.fromUri(serverUrl).build()),
            CredentialsMatchers.withId(value)) != null) {
        return FormValidation.error(Messages.SSHCheckoutTrait_incompatibleCredentials());
    }
    return FormValidation.warning(Messages.SSHCheckoutTrait_missingCredentials());
}
 
开发者ID:jenkinsci,项目名称:gitea-plugin,代码行数:39,代码来源:SSHCheckoutTrait.java

示例9: doCheckCredentialsId

import hudson.model.Item; //导入方法依赖的package包/类
public FormValidation doCheckCredentialsId(
    @AncestorInPath Item context, @QueryParameter String remote, @QueryParameter String value) {
  if (context == null && !Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER)
      || context != null && !context.hasPermission(Item.EXTENDED_READ)) {
    return FormValidation.ok();
  }

  value = Util.fixEmptyAndTrim(value);
  if (value == null) {
    return FormValidation.ok();
  }

  remote = Util.fixEmptyAndTrim(remote);
  if (remote == null)
  // not set, can't check
  {
    return FormValidation.ok();
  }

  for (ListBoxModel.Option o :
      CredentialsProvider.listCredentials(
          StandardUsernameCredentials.class,
          context,
          context instanceof Queue.Task
              ? Tasks.getAuthenticationOf((Queue.Task) context)
              : ACL.SYSTEM,
          URIRequirementBuilder.fromUri(remote).build(),
          GitClient.CREDENTIALS_MATCHER)) {
    if (StringUtils.equals(value, o.value)) {
      // TODO check if this type of credential is acceptable to the Git client or does it merit warning
      // NOTE: we would need to actually lookup the credential to do the check, which may require
      // fetching the actual credential instance from a remote credentials store. Perhaps this is
      // not required
      return FormValidation.ok();
    }
  }
  // no credentials available, can't check
  return FormValidation.warning("Cannot find any credentials with id " + value);
}
 
开发者ID:GerritForge,项目名称:gerrit-plugin,代码行数:40,代码来源:GerritSCMSource.java

示例10: doFillCredentialsIdItems

import hudson.model.Item; //导入方法依赖的package包/类
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath final Item context) {
    if (context != null && !context.hasPermission(Item.CONFIGURE)) {
        return new StandardListBoxModel();
    }

    return new StandardListBoxModel()
            .withMatching(CredentialsMatchers.anyOf(
                    CredentialsMatchers.instanceOf(BrowserStackCredentials.class)),
                    CredentialsProvider.lookupCredentials(
                            BrowserStackCredentials.class,
                            context,
                            ACL.SYSTEM,
                            new ArrayList<DomainRequirement>()));
}
 
开发者ID:jenkinsci,项目名称:browserstack-integration-plugin,代码行数:15,代码来源:BrowserStackBuildWrapperDescriptor.java

示例11: doFillCredentialsIdItems

import hudson.model.Item; //导入方法依赖的package包/类
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Item item, @QueryParameter String uri) {
    if (item == null && !Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER) ||
        item != null && !item.hasPermission(Item.EXTENDED_READ)) {
        return new StandardListBoxModel();
    }
    List<DomainRequirement> domainRequirements = URIRequirementBuilder.fromUri(uri).build();
    domainRequirements.add(new DockerServerDomainRequirement());
    return new StandardListBoxModel()
            .withEmptySelection()
            .withMatching(
                    AuthenticationTokens.matcher(KeyMaterialFactory.class),
                    CredentialsProvider
                            .lookupCredentials(BASE_CREDENTIAL_TYPE, item, null, domainRequirements)
            );
}
 
开发者ID:jenkinsci,项目名称:docker-commons-plugin,代码行数:16,代码来源:DockerServerEndpoint.java

示例12: doFillCredentialsIdItems

import hudson.model.Item; //导入方法依赖的package包/类
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Item project,
                                             @QueryParameter String serverAddress) {
    if (project == null || !project.hasPermission(Item.CONFIGURE)) {
        return new StandardListBoxModel();
    }
    return new StandardListBoxModel()
        .withEmptySelection()
        .withMatching(
            DockerCommand.CREDENTIALS_MATCHER,
            CredentialsProvider.lookupCredentials(StandardCredentials.class,
                project,
                ACL.SYSTEM,
                URIRequirementBuilder.fromUri(serverAddress).build()));
}
 
开发者ID:jenkinsci,项目名称:docker-build-step-plugin,代码行数:15,代码来源:DockerCredConfig.java

示例13: doFillCredentialsIdItems

import hudson.model.Item; //导入方法依赖的package包/类
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Item owner) {
    if (owner == null || !owner.hasPermission(Item.CONFIGURE)) {
        return new ListBoxModel();
    }
    // when configuring the job, you only want those credentials that are available to ACL.SYSTEM selectable
    // as we cannot select from a user's credentials unless they are the only user submitting the build
    // (which we cannot assume) thus ACL.SYSTEM is correct here.
    return new Model().withAll(CredentialsProvider.lookupCredentials(type(), owner, ACL.SYSTEM, Collections.<DomainRequirement>emptyList()));
}
 
开发者ID:jenkinsci,项目名称:credentials-binding-plugin,代码行数:10,代码来源:BindingDescriptor.java


注:本文中的hudson.model.Item.hasPermission方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。