本文整理汇总了Java中com.cloudbees.plugins.credentials.domains.DomainRequirement类的典型用法代码示例。如果您正苦于以下问题:Java DomainRequirement类的具体用法?Java DomainRequirement怎么用?Java DomainRequirement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DomainRequirement类属于com.cloudbees.plugins.credentials.domains包,在下文中一共展示了DomainRequirement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCredentials
import com.cloudbees.plugins.credentials.domains.DomainRequirement; //导入依赖的package包/类
/**
* Get the {@link StandardCredentials}.
*
* @return the credentials matching the {@link #credentialsId} or {@code null} is {@code #credentialsId} is blank
* @throws AbortException if no {@link StandardCredentials} matching {@link #credentialsId} is found
*/
private StandardCredentials getCredentials(Run<?, ?> build) throws AbortException {
if (StringUtils.isBlank(credentialsId)) {
return null;
}
StandardCredentials result = CredentialsProvider.findCredentialById(
credentialsId,
StandardCredentials.class,
build,
Collections.<DomainRequirement>emptyList());
if (result == null) {
throw new AbortException("No credentials found for id \"" + credentialsId + "\"");
}
return result;
}
示例2: doFillPrincipalCredentialIdItems
import com.cloudbees.plugins.credentials.domains.DomainRequirement; //导入依赖的package包/类
public ListBoxModel doFillPrincipalCredentialIdItems(
@AncestorInPath Item item,
@QueryParameter String credentialsId) {
StandardListBoxModel result = new StandardListBoxModel();
if (item == null) {
if (!Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER)) {
return result.includeCurrentValue(credentialsId);
}
} else {
if (!item.hasPermission(Item.EXTENDED_READ)
&& !item.hasPermission(CredentialsProvider.USE_ITEM)) {
return result.includeCurrentValue(credentialsId);
}
}
List<AzureCredentials> creds = CredentialsProvider.lookupCredentials(AzureCredentials.class, item, ACL.SYSTEM, Collections.<DomainRequirement>emptyList());
for (AzureCredentials cred
:
creds) {
result.add(cred.getId());
}
return result.includeEmptyValue()
.includeCurrentValue(credentialsId);
}
示例3: doFillCredentialsIdItems
import com.cloudbees.plugins.credentials.domains.DomainRequirement; //导入依赖的package包/类
/**
* Fills in the Login Credentials selection box with applicable connections.
*
* @param context
* filter for login credentials
* @param credentialsId
* existing login credentials; can be null
* @param project
* the Jenkins project
*
* @return login credentials selection
*/
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Jenkins context, @QueryParameter String credentialsId,
@AncestorInPath Item project)
{
List<StandardUsernamePasswordCredentials> creds = CredentialsProvider.lookupCredentials(
StandardUsernamePasswordCredentials.class, project, ACL.SYSTEM,
Collections.<DomainRequirement> emptyList());
ListBoxModel model = new ListBoxModel();
model.add(new Option(StringUtils.EMPTY, StringUtils.EMPTY, false));
for (StandardUsernamePasswordCredentials c : creds)
{
boolean isSelected = false;
if (credentialsId != null)
{
isSelected = credentialsId.matches(c.getId());
}
String description = Util.fixEmptyAndTrim(c.getDescription());
model.add(new Option(c.getUsername() + (description != null ? " (" + description + ')' : StringUtils.EMPTY), //$NON-NLS-1$
c.getId(), isSelected));
}
return model;
}
示例4: doFillCredentialsIdItems
import com.cloudbees.plugins.credentials.domains.DomainRequirement; //导入依赖的package包/类
/**
* Fills in the Login Credentials selection box with applicable Jenkins credentials.
*
* @param context
* filter for credentials
* @param credentialsId
* existing login credentials; can be null
* @param project
* the Jenkins project
*
* @return credential selections
*/
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Jenkins context, @QueryParameter String credentialsId, @AncestorInPath Item project)
{
List<StandardUsernamePasswordCredentials> creds = CredentialsProvider.lookupCredentials(
StandardUsernamePasswordCredentials.class, project, ACL.SYSTEM,
Collections.<DomainRequirement> emptyList());
StandardListBoxModel model = new StandardListBoxModel();
model.add(new Option(StringUtils.EMPTY, StringUtils.EMPTY, false));
for (StandardUsernamePasswordCredentials c : creds)
{
boolean isSelected = false;
if (credentialsId != null)
{
isSelected = credentialsId.matches(c.getId());
}
String description = Util.fixEmptyAndTrim(c.getDescription());
model.add(new Option(c.getUsername() + (description != null ? " (" + description + ')' : StringUtils.EMPTY), //$NON-NLS-1$
c.getId(), isSelected));
}
return model;
}
示例5: getLoginInformation
import com.cloudbees.plugins.credentials.domains.DomainRequirement; //导入依赖的package包/类
/**
* Retrieves login information given a credential ID.
*
* @param project
* the Jenkins project
*
* @return a Jenkins credential with login information
*/
protected StandardUsernamePasswordCredentials getLoginInformation(Item project)
{
StandardUsernamePasswordCredentials credential = null;
List<StandardUsernamePasswordCredentials> credentials = CredentialsProvider.lookupCredentials(
StandardUsernamePasswordCredentials.class, project, ACL.SYSTEM, Collections.<DomainRequirement> emptyList());
IdMatcher matcher = new IdMatcher(getCredentialsId());
for (StandardUsernamePasswordCredentials c : credentials)
{
if (matcher.matches(c))
{
credential = c;
}
}
return credential;
}
示例6: getLoginInformation
import com.cloudbees.plugins.credentials.domains.DomainRequirement; //导入依赖的package包/类
/**
* Retrieves login information given a credential ID
*
* @param project
* the Jenkins project
*
* @return a Jenkins credential with login information
*/
protected StandardUsernamePasswordCredentials getLoginInformation(Item project)
{
StandardUsernamePasswordCredentials credential = null;
List<StandardUsernamePasswordCredentials> credentials = CredentialsProvider.lookupCredentials(
StandardUsernamePasswordCredentials.class, project, ACL.SYSTEM, Collections.<DomainRequirement> emptyList());
IdMatcher matcher = new IdMatcher(getCredentialsId());
for (StandardUsernamePasswordCredentials c : credentials)
{
if (matcher.matches(c))
{
credential = c;
}
}
return credential;
}
示例7: getCurrentToken
import com.cloudbees.plugins.credentials.domains.DomainRequirement; //导入依赖的package包/类
public static String getCurrentToken() {
String credentialsId = GlobalPluginConfiguration.get()
.getCredentialsId();
if (credentialsId.equals("")) {
return "";
}
OpenShiftToken token = CredentialsMatchers.firstOrNull(
CredentialsProvider.lookupCredentials(OpenShiftToken.class,
Jenkins.getActiveInstance(), ACL.SYSTEM,
Collections.<DomainRequirement> emptyList()),
CredentialsMatchers.withId(credentialsId));
if (token != null) {
return token.getToken();
}
return "";
}
示例8: doFillCredentialsIdItems
import com.cloudbees.plugins.credentials.domains.DomainRequirement; //导入依赖的package包/类
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Item item, @QueryParameter String credentialsId) {
StandardListBoxModel result = new StandardListBoxModel();
if (item == null) {
if (!Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER)) {
return result.add(credentialsId);
}
} else {
if (!item.hasPermission(Item.EXTENDED_READ)
&& !item.hasPermission(CredentialsProvider.USE_ITEM)) {
return result.add(credentialsId);
}
}
return result
.withEmptySelection()
.withAll(CredentialsProvider.lookupCredentials(StandardUsernamePasswordCredentials.class, item, null, Collections.<DomainRequirement>emptyList()))
.withMatching(CredentialsMatchers.withId(credentialsId));
}
示例9: doFillCredentialsIDItems
import com.cloudbees.plugins.credentials.domains.DomainRequirement; //导入依赖的package包/类
public static ListBoxModel doFillCredentialsIDItems(@AncestorInPath Jenkins context) {
if (context == null || !context.hasPermission(Item.CONFIGURE)) {
return new StandardListBoxModel();
}
List<DomainRequirement> domainRequirements = new ArrayList<DomainRequirement>();
return new StandardListBoxModel()
.withEmptySelection()
.withMatching(
CredentialsMatchers.anyOf(
CredentialsMatchers.instanceOf(ConduitCredentials.class)),
CredentialsProvider.lookupCredentials(
StandardCredentials.class,
context,
ACL.SYSTEM,
domainRequirements));
}
示例10: FigShareNotifier
import com.cloudbees.plugins.credentials.domains.DomainRequirement; //导入依赖的package包/类
/**
* Constructor called from a Jelly view. The parameters are given by a user.
*
* @param credentialsId figshare credential ID, selected out of a combo box
* @param articleTitle figshare article title
* @param articleDescription figshare article description
* @param antPattern an ant-like pattern (e.g. **\/*.png)
*/
@DataBoundConstructor
public FigShareNotifier(String credentialsId, String articleTitle, String articleDescription, String antPattern) {
this.credentialsId = credentialsId;
this.articleTitle = articleTitle;
this.articleDescription = articleDescription;
this.antPattern = antPattern;
// Get credential defined by user, using credential ID
List<FigShareOauthCredentials> credentials = CredentialsProvider.lookupCredentials(
FigShareOauthCredentials.class, Jenkins.getInstance(), ACL.SYSTEM,
Collections.<DomainRequirement> emptyList());
FigShareOauthCredentials credential = CredentialsMatchers.firstOrNull(credentials,
CredentialsMatchers.allOf(CredentialsMatchers.withId(credentialsId)));
this.credential = credential;
if (null == credential) {
LOGGER.warning(String.format(
"Could not locate credential with ID %s. figshare integration is disabled for this notifier",
credentialsId));
}
}
示例11: getToken
import com.cloudbees.plugins.credentials.domains.DomainRequirement; //导入依赖的package包/类
/**
* Plugins that want to refer to a {@link IdCredentials} should do so via ID string,
* and use this method to resolve it and convert to {@link DockerRegistryToken}.
*
* @param context
* If you are a build step trying to access DockerHub in the context of a build/job,
* specify that job. Otherwise null. If you are scoped to something else, you might
* have to interact with {@link CredentialsProvider} directly.
*/
public @CheckForNull
DockerRegistryToken getToken(Item context) {
if (credentialsId == null) {
return null;
}
// as a build step, your access to credentials are constrained by what the build
// can access, hence Jenkins.getAuthentication()
List<DomainRequirement> requirements = Collections.emptyList();
try {
requirements = Collections.<DomainRequirement>singletonList(new HostnameRequirement(getEffectiveUrl().getHost()));
} catch (IOException e) {
// shrug off this error and move on. We are matching with ID anyway.
}
// look for subtypes that know how to create a token, such as Google Container Registry
return AuthenticationTokens.convert(DockerRegistryToken.class, firstOrNull(CredentialsProvider.lookupCredentials(
IdCredentials.class, context, Jenkins.getAuthentication(),requirements),
allOf(AuthenticationTokens.matcher(DockerRegistryToken.class), withId(credentialsId))));
}
示例12: doFillCredentialsIdItems
import com.cloudbees.plugins.credentials.domains.DomainRequirement; //导入依赖的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()
)
);
}
示例13: newKeyMaterialFactory
import com.cloudbees.plugins.credentials.domains.DomainRequirement; //导入依赖的package包/类
/**
* Makes the key materials available locally and returns {@link KeyMaterialFactory} that gives you the parameters
* needed to access it.
*/
public KeyMaterialFactory newKeyMaterialFactory(@Nonnull Item context, @Nonnull VirtualChannel target) throws IOException, InterruptedException {
// as a build step, your access to credentials are constrained by what the build
// can access, hence Jenkins.getAuthentication()
DockerServerCredentials creds=null;
if (credentialsId!=null) {
List<DomainRequirement> domainRequirements = URIRequirementBuilder.fromUri(getUri()).build();
domainRequirements.add(new DockerServerDomainRequirement());
creds = CredentialsMatchers.firstOrNull(
CredentialsProvider.lookupCredentials(
DockerServerCredentials.class, context, Jenkins.getAuthentication(),
domainRequirements),
CredentialsMatchers.withId(credentialsId)
);
}
// the directory needs to be outside workspace to avoid prying eyes
FilePath dotDocker = dotDocker(target);
dotDocker.mkdirs();
// ServerKeyMaterialFactory.materialize creates a random subdir if one is needed:
return newKeyMaterialFactory(dotDocker, creds);
}
示例14: doFillCredentialsIdItems
import com.cloudbees.plugins.credentials.domains.DomainRequirement; //导入依赖的package包/类
/**
* Stapler helper method.
*
* @param context
* the context.
* @param remoteBase
* the remote base.
* @return list box model.
* @throws URISyntaxException
*/
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Item context, @QueryParameter String serverAPIUrl) throws URISyntaxException {
List<DomainRequirement> domainRequirements = URIRequirementBuilder.fromUri(serverAPIUrl).build();
return new StandardListBoxModel()
.withEmptySelection()
.withMatching(
CredentialsMatchers.anyOf(
CredentialsMatchers.instanceOf(StandardUsernamePasswordCredentials.class),
CredentialsMatchers.instanceOf(StringCredentials.class)),
CredentialsProvider.lookupCredentials(StandardCredentials.class,
context,
ACL.SYSTEM,
domainRequirements)
);
}
示例15: getCredentials
import com.cloudbees.plugins.credentials.domains.DomainRequirement; //导入依赖的package包/类
/**
* Get the {@link StandardCredentials}.
*
* @return the credentials matching the {@link #credentialsId} or {@code null} is {@code #credentialsId} is blank
* @throws AbortException if no {@link StandardCredentials} matching {@link #credentialsId} is found
*/
@CheckForNull
private StandardCredentials getCredentials() throws AbortException {
if (StringUtils.isBlank(credentialsId)) {
return null;
}
StandardCredentials result = CredentialsMatchers.firstOrNull(
CredentialsProvider.lookupCredentials(StandardCredentials.class,
Jenkins.getInstance(), ACL.SYSTEM, Collections.<DomainRequirement>emptyList()),
CredentialsMatchers.withId(credentialsId)
);
if (result == null) {
throw new AbortException("No credentials found for id \"" + credentialsId + "\"");
}
return result;
}