private static CredentialsMatcher githubScanCredentialsMatcher() { // TODO OAuth credentials return CredentialsMatchers.anyOf(CredentialsMatchers.instanceOf(StandardUsernamePasswordCredentials.class)); }
/** * {@inheritDoc} */ @Override public void exitExpression(CQLParser.ExpressionContext ctx) { if (ctx.AND() != null) { CredentialsMatcher second = expression.pop(); CredentialsMatcher first = expression.pop(); expression.push(CredentialsMatchers.allOf(first, second)); } else if (ctx.OR() != null) { CredentialsMatcher second = expression.pop(); CredentialsMatcher first = expression.pop(); expression.push(CredentialsMatchers.anyOf(first, second)); } else { expression.push(primary); } }
/** * {@inheritDoc} */ @Override public void exitExpression(CQLParser.ExpressionContext ctx) { if (ctx.AND() != null) { CredentialsMatcher second = expression.pop(); CredentialsMatcher first = expression.pop(); expression.push(CredentialsMatchers.allOf(first, second)); } else if (ctx.OR() != null) { CredentialsMatcher second = expression.pop(); CredentialsMatcher first = expression.pop(); expression.push(CredentialsMatchers.anyOf(first, second)); } else { expression.push(primary); } }
/** * Returns a {@link CredentialsMatcher} that matches the generic types of credential that are valid for use over * SSH. * When you know the connection type you will be using, it is better to use {@link #matcher(Class)}. * * @return a {@link CredentialsMatcher} that matches the generic types of credential that are valid for use over * SSH. */ public static CredentialsMatcher matcher() { return anyOf( instanceOf(StandardUsernamePasswordCredentials.class), instanceOf(SSHUserPrivateKey.class) ); }
/** * Creates a matcher that matches when none of the supplied matchers match. * * @param matchers the matchers to match. * @return a matcher that matches when none of the supplied matchers match. */ @NonNull public static CredentialsMatcher noneOf(@NonNull CredentialsMatcher... matchers) { return not(anyOf(matchers)); }
/** * Creates a matcher that matches when none of the supplied matchers match. * * @param matchers the matchers to match. * @return a matcher that matches when none of the supplied matchers match. */ @NonNull public static CredentialsMatcher noneOf(@NonNull CredentialsMatcher... matchers) { return not(anyOf(matchers)); }
CredentialsMatchers.anyOf( matchers.toArray(new CredentialsMatcher[0])), credentials
public ListBoxModel doFillCredentialIdItems(@AncestorInPath Jenkins context) { return new StandardListBoxModel() .withEmptySelection() .withMatching( CredentialsMatchers.anyOf( CredentialsMatchers.instanceOf(StandardUsernamePasswordCredentials.class) ), CredentialsProvider.lookupCredentials(StandardUsernamePasswordCredentials.class, context, ACL.SYSTEM, new ArrayList<DomainRequirement>()) ); }
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Item item) { return new StandardListBoxModel().withEmptySelection().withMatching( CredentialsMatchers.anyOf( CredentialsMatchers.instanceOf(StringCredentials.class), CredentialsMatchers.instanceOf(UsernamePasswordCredentials.class) ), CredentialsProvider.lookupCredentials(StandardCredentials.class, item, null, Collections.<DomainRequirement>emptyList()) ); }
ACL.SYSTEM, URIRequirementBuilder.fromUri(remote).build()), CredentialsMatchers.allOf(idMatcher(credentialsId), CredentialsMatchers.anyOf(CredentialsMatchers.instanceOf( StandardCredentials.class), CredentialsMatchers.instanceOf( SSHUserPrivateKey.class)))); ACL.SYSTEM, Collections.<DomainRequirement>emptyList()), CredentialsMatchers.allOf(idMatcher(c.getValue()), CredentialsMatchers.anyOf(CredentialsMatchers.instanceOf( StandardCredentials.class), CredentialsMatchers.instanceOf( SSHUserPrivateKey.class))));
public static Optional<StandardCredentials> findCredentials( Item item, String credentialsId, String uri) { if (isNullOrEmpty(credentialsId)) { return absent(); } return fromNullable( CredentialsMatchers.firstOrNull( CredentialsProvider.lookupCredentials( StandardCredentials.class, item, item instanceof Queue.Task ? Tasks.getAuthenticationOf((Queue.Task) item) : ACL.SYSTEM, URIRequirementBuilder.fromUri(uri).build()), CredentialsMatchers.allOf( CredentialsMatchers.withId(credentialsId), CredentialsMatchers.anyOf( CredentialsMatchers.instanceOf(StandardUsernamePasswordCredentials.class), CredentialsMatchers.instanceOf(StringCredentials.class))))); }
.withEmptySelection() .withMatching( CredentialsMatchers.anyOf( CredentialsMatchers.instanceOf(StandardUsernamePasswordCredentials.class), CredentialsMatchers.instanceOf(StandardCertificateCredentials.class),
public static ListBoxModel fillPluginCredentials(Item project, Authentication authentication) { if (project != null && !project.hasPermission(Item.CONFIGURE)) { return new StandardListBoxModel(); } List<DomainRequirement> domainRequirements = Collections.emptyList(); return new StandardListBoxModel() .withEmptySelection() .withMatching( CredentialsMatchers.anyOf( CredentialsMatchers.instanceOf(StandardUsernamePasswordCredentials.class), CredentialsMatchers.instanceOf(StandardCertificateCredentials.class) ), CredentialsProvider.lookupCredentials(StandardCredentials.class, project, authentication, domainRequirements) ); }
public ListBoxModel fillCredentialsIdItems(@CheckForNull Item context, String remote) { List<DomainRequirement> domainRequirements; if (remote == null) { domainRequirements = Collections.<DomainRequirement>emptyList(); } else { domainRequirements = URIRequirementBuilder.fromUri(remote.trim()).build(); } return new StandardListBoxModel() .withEmptySelection() .withMatching( CredentialsMatchers.anyOf( CredentialsMatchers.instanceOf(StandardUsernamePasswordCredentials.class), CredentialsMatchers.instanceOf(StandardCertificateCredentials.class), CredentialsMatchers.instanceOf(SSHUserPrivateKey.class) ), CredentialsProvider.lookupCredentials(StandardCredentials.class, context, ACL.SYSTEM, domainRequirements) ); }
public static ListBoxModel doFillCredentialsIdItems(String endpointUrl) { return new StandardListBoxModel() .withEmptySelection() .withMatching( CredentialsMatchers.anyOf(CredentialsMatchers.instanceOf(TokenCredentialsImpl.class), CredentialsMatchers.instanceOf(UsernamePasswordCredentials.class)), CredentialsProvider.lookupCredentials(StandardCredentials.class, Jenkins.getInstance(), ACL.SYSTEM, URIRequirementBuilder.fromUri(endpointUrl).build())); }
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Item item, @QueryParameter String serverUrl) { return new StandardListBoxModel() .withEmptySelection() .withMatching( CredentialsMatchers.anyOf( CredentialsMatchers.instanceOf(StandardUsernamePasswordCredentials.class), CredentialsMatchers.instanceOf(TokenProducer.class), CredentialsMatchers.instanceOf(StandardCertificateCredentials.class), CredentialsMatchers.instanceOf(FileCredentials.class) ), CredentialsProvider.lookupCredentials( StandardCredentials.class, item, null, URIRequirementBuilder.fromUri(serverUrl).build() ) ); }
public ListBoxModel doFillCredentialsIdItems(@QueryParameter String serverUrl) { return new StandardListBoxModel().withEmptySelection() // .withMatching( // CredentialsMatchers.anyOf( CredentialsMatchers.instanceOf(StandardUsernamePasswordCredentials.class), CredentialsMatchers.instanceOf(FileCredentials.class), CredentialsMatchers.instanceOf(TokenProducer.class), CredentialsMatchers.instanceOf( org.jenkinsci.plugins.kubernetes.credentials.TokenProducer.class), CredentialsMatchers.instanceOf(StandardCertificateCredentials.class), CredentialsMatchers.instanceOf(StringCredentials.class)), // CredentialsProvider.lookupCredentials(StandardCredentials.class, // Jenkins.getInstance(), // ACL.SYSTEM, // serverUrl != null ? URIRequirementBuilder.fromUri(serverUrl).build() : Collections.EMPTY_LIST // )); }
private SVNRepositoryView openSession(SVNURL repoURL) throws SVNException, IOException { return new SVNRepositoryView(repoURL, credentialsId == null ? null : CredentialsMatchers .firstOrNull(CredentialsProvider.lookupCredentials(StandardCredentials.class, getOwner(), ACL.SYSTEM, URIRequirementBuilder.fromUri(repoURL.toString()).build()), CredentialsMatchers.allOf(CredentialsMatchers.withId(credentialsId), CredentialsMatchers.anyOf(CredentialsMatchers.instanceOf(StandardCredentials.class), CredentialsMatchers.instanceOf(SSHUserPrivateKey.class))))); }
@Override public SCMFileSystem build(Item owner, SCM scm, SCMRevision rev) throws IOException, InterruptedException { if (rev != null && !(rev instanceof SubversionSCMSource.SCMRevisionImpl)) { return null; } try { SubversionSCM svn = (SubversionSCM) scm; ModuleLocation moduleLocation = svn.getLocations()[0]; StandardCredentials credentials = null; SVNURL repoURL = moduleLocation.getSVNURL(); if (moduleLocation.credentialsId != null) { credentials = CredentialsMatchers.firstOrNull( CredentialsProvider.lookupCredentials(StandardCredentials.class, owner, ACL.SYSTEM, URIRequirementBuilder.fromUri(repoURL.toString()).build()), CredentialsMatchers.allOf(CredentialsMatchers.withId(moduleLocation.credentialsId), CredentialsMatchers.anyOf(CredentialsMatchers.instanceOf(StandardCredentials.class), CredentialsMatchers.instanceOf(SSHUserPrivateKey.class)))); } SVNRepository repository = createRepository(repoURL, credentials); return new SubversionSCMFileSystem(repository, rev); } catch (SVNException e) { throw new IOException("failed to create SVNRepositoryView", e); } }
public static ListBoxModel doFillCredentialsIdItems(Item item, String credentialsId, String uri) { 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() // .includeMatchingAs( item instanceof Queue.Task ? Tasks.getAuthenticationOf((Queue.Task) item) : ACL.SYSTEM, item, StandardCredentials.class, URIRequirementBuilder.fromUri(uri).build(), CredentialsMatchers.anyOf( CredentialsMatchers.instanceOf(StandardUsernamePasswordCredentials.class), CredentialsMatchers.instanceOf(StringCredentials.class))) .includeCurrentValue(credentialsId); }