public ListBoxModel doFillCredentialsIdItems(@AncestorInPath ItemGroup context, @QueryParameter String currentValue) { if (!(context instanceof AccessControlled ? (AccessControlled) context : Jenkins.getInstance()).hasPermission(Computer.CONFIGURE)) { return new StandardUsernameListBoxModel().includeCurrentValue(currentValue); } return new StandardUsernameListBoxModel().includeMatchingAs( ACL.SYSTEM, context, StandardUsernameCredentials.class, Collections.<DomainRequirement>singletonList(SSHLauncher.SSH_SCHEME), SSHAuthenticator.matcher(Connection.class)).includeCurrentValue(currentValue); }
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath SCMSourceOwner owner, @QueryParameter String source) { if (!hasAccessToCredentialsMetadata(owner)) { return new ListBoxModel(); } return new StandardUsernameListBoxModel() .withEmptySelection() .withAll(availableCredentials(owner, source)); }
public ListBoxModel doFillCloudCredentialsIdItems(@AncestorInPath ItemGroup context, @QueryParameter String currentValue) { if (!(context instanceof AccessControlled ? (AccessControlled) context : Jenkins.getInstance()).hasPermission(Computer.CONFIGURE)) { return new StandardUsernameListBoxModel().includeCurrentValue(currentValue); } return new StandardUsernameListBoxModel() .includeAs(ACL.SYSTEM, context, StandardUsernameCredentials.class).includeCurrentValue(currentValue); }
/** * Populate the list of credentials available to the job. * * @return the list box model. */ @SuppressWarnings("unused") // used by stapler public ListBoxModel doFillCredentialsItems() { Item item = Stapler.getCurrentRequest().findAncestorObject(Item.class); return new StandardUsernameListBoxModel().withAll( CredentialsProvider.lookupCredentials(SSHUserPrivateKey.class, item, ACL.SYSTEM, Collections.<DomainRequirement>emptyList()) ); }
@SuppressWarnings("unused") public ListBoxModel doFillCredentialsIdItems(@QueryParameter String apiUrl, @QueryParameter String credentialsId) { if (!Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER)) { return new StandardUsernameListBoxModel().includeCurrentValue(credentialsId); } return new StandardUsernameListBoxModel() .includeEmptyValue() .includeMatchingAs( ACL.SYSTEM, Jenkins.getInstance(), StandardUsernamePasswordCredentials.class, fromUri(defaultIfBlank(apiUrl, GITHUB_URL)).build(), CredentialsMatchers.always() ) .includeMatchingAs( Jenkins.getAuthentication(), Jenkins.getInstance(), StandardUsernamePasswordCredentials.class, fromUri(defaultIfBlank(apiUrl, GITHUB_URL)).build(), CredentialsMatchers.always() ); }
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Item context, @QueryParameter String source) { if (context == null || !context.hasPermission(Item.CONFIGURE)) { return new ListBoxModel(); } return new StandardUsernameListBoxModel() .includeEmptyValue() .includeAs(context instanceof Queue.Task ? Tasks.getDefaultAuthenticationOf((Queue.Task) context) : ACL.SYSTEM, context, StandardUsernamePasswordCredentials.class, URIRequirementBuilder.fromUri(source).build() ); } }
@Restricted(DoNotUse.class) @RequirePOST public ListBoxModel doFillCredentialsIdItems(@AncestorInPath ItemGroup context) { if (!(context instanceof AccessControlled ? (AccessControlled) context : Jenkins.getActiveInstance()).hasPermission(Computer.CONFIGURE)) { return new ListBoxModel(); } List<StandardUsernameCredentials> credentials = CredentialsProvider.lookupCredentials( StandardUsernameCredentials.class, context, ACL.SYSTEM, SSHLauncher.SSH_SCHEME ); return new StandardUsernameListBoxModel() .withMatching(SSHAuthenticator.matcher(Connection.class), credentials) .withEmptySelection() ; } }
public ListBoxModel doFillAdminCredentialsIdItems(@AncestorInPath ItemGroup context, @QueryParameter String currentValue) { if (!(context instanceof AccessControlled ? (AccessControlled) context : Jenkins.getInstance()).hasPermission(Computer.CONFIGURE)) { return new StandardUsernameListBoxModel().includeCurrentValue(currentValue); } return new StandardUsernameListBoxModel().includeMatchingAs( ACL.SYSTEM, context, StandardUsernameCredentials.class, Collections.<DomainRequirement>singletonList(SSHLauncher.SSH_SCHEME), SSHAuthenticator.matcher(Connection.class)).includeCurrentValue(currentValue); }
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath ItemGroup context, @QueryParameter String currentValue) { if (!(context instanceof AccessControlled ? (AccessControlled) context : Jenkins.getInstance()).hasPermission(Computer.CONFIGURE)) { return new StandardUsernameListBoxModel().includeCurrentValue(currentValue); } return new StandardUsernameListBoxModel() .includeAs(ACL.SYSTEM, context, StandardUsernameCredentials.class).includeCurrentValue(currentValue); }
public ListBoxModel doFillGlobalCredentialsIdItems() { Job owner = null; List<DomainRequirement> apiEndpoint = URIRequirementBuilder.fromUri(BitbucketApi.OAUTH_ENDPOINT).build(); return new StandardUsernameListBoxModel() .withEmptySelection() .withAll(CredentialsProvider.lookupCredentials(StandardUsernamePasswordCredentials.class, owner, null, apiEndpoint)); }
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath ItemGroup context, @QueryParameter String credentialsId) { AccessControlled _context = (context instanceof AccessControlled ? (AccessControlled) context : Jenkins.getInstance()); if (_context == null || !_context.hasPermission(Computer.CONFIGURE)) { return new StandardUsernameListBoxModel() .includeCurrentValue(credentialsId); } return new StandardUsernameListBoxModel() .includeMatchingAs( ACL.SYSTEM, context, StandardUsernameCredentials.class, Collections.singletonList(SSHLauncher.SSH_SCHEME), SSHAuthenticator.matcher(Connection.class) ) .includeCurrentValue(credentialsId); }
public ListBoxModel doFillCloudGlobalKeyIdItems(@AncestorInPath ItemGroup context, @QueryParameter String currentValue) { if (!(context instanceof AccessControlled ? (AccessControlled) context : Jenkins.getInstance()).hasPermission(Computer.CONFIGURE)) { return new StandardUsernameListBoxModel().includeCurrentValue(currentValue); } return new StandardUsernameListBoxModel() .includeAs(ACL.SYSTEM, context, SSHUserPrivateKey.class).includeCurrentValue(currentValue); }
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Job<?,?> owner, @QueryParameter String source) { if (!hasAccessToCredentialsMetadata(owner)) { return new ListBoxModel(); } return new StandardUsernameListBoxModel() .withEmptySelection() .withAll(availableCredentials(owner, new EnvVars( ).expand( source ))); }
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath ItemGroup context, @QueryParameter String credentialsId) { AccessControlled _context = (context instanceof AccessControlled ? (AccessControlled) context : Jenkins.getInstance()); if (_context == null || !_context.hasPermission(Computer.CONFIGURE)) { return new StandardUsernameListBoxModel() .includeCurrentValue(credentialsId); } return new StandardUsernameListBoxModel() .includeMatchingAs( ACL.SYSTEM, context, StandardUsernameCredentials.class, Collections.<DomainRequirement>singletonList(SSHLauncher.SSH_SCHEME), SSHAuthenticator.matcher(Connection.class) ) .includeCurrentValue(credentialsId); }
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath ItemGroup context, @QueryParameter String serverId) { AccessControlled _context = (context instanceof AccessControlled ? (AccessControlled) context : Jenkins.getActiveInstance()); if (_context == null || !_context.hasPermission(Item.CONFIGURE)) { return new StandardUsernameListBoxModel().includeCurrentValue(serverId); } List<DomainRequirement> domainRequirements = Collections.emptyList(); if (StringUtils.isNotBlank(serverId)) { domainRequirements = Collections.<DomainRequirement> singletonList(new MavenServerIdRequirement(serverId)); } // @formatter:off return new StandardUsernameListBoxModel().includeAs( context instanceof Queue.Task ? Tasks.getDefaultAuthenticationOf((Queue.Task)context) : ACL.SYSTEM, context, StandardUsernameCredentials.class, domainRequirements ) .includeCurrentValue(serverId); // @formatter:on }
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath ItemGroup context, @QueryParameter String url) { AccessControlled _context = (context instanceof AccessControlled ? (AccessControlled) context : Jenkins.getInstance()); if (_context == null || !_context.hasPermission(Jenkins.ADMINISTER)) { return new StandardUsernameListBoxModel(); } return new StandardUsernameListBoxModel() .withEmptySelection() .withAll( CredentialsProvider.lookupCredentials( StandardUsernamePasswordCredentials.class, Jenkins.getInstance(), ACL.SYSTEM, URIRequirementBuilder.fromUri(url).build() ) ); }
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath ItemGroup context, @QueryParameter String host, @QueryParameter String port, @QueryParameter String credentialsId) { AccessControlled _context = (context instanceof AccessControlled ? (AccessControlled) context : Jenkins.getInstance()); if (_context == null || !_context.hasPermission(Computer.CONFIGURE)) { return new StandardUsernameListBoxModel() .includeCurrentValue(credentialsId); } try { int portValue = Integer.parseInt(port); return new StandardUsernameListBoxModel() .includeMatchingAs( ACL.SYSTEM, Jenkins.getActiveInstance(), StandardUsernameCredentials.class, Collections.<DomainRequirement>singletonList( new HostnamePortRequirement(host, portValue) ), SSHAuthenticator.matcher(Connection.class)) .includeCurrentValue(credentialsId); // always add the current value last in case already present } catch (NumberFormatException ex) { return new StandardUsernameListBoxModel() .includeCurrentValue(credentialsId); } }
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Job<?,?> owner) { if (owner == null || !owner.hasPermission(Item.CONFIGURE)) { return new ListBoxModel(); } List<DomainRequirement> apiEndpoint = URIRequirementBuilder.fromUri(BitbucketApi.OAUTH_ENDPOINT).build(); return new StandardUsernameListBoxModel() .withEmptySelection() .withAll(CredentialsProvider.lookupCredentials(StandardUsernamePasswordCredentials.class, owner, null, apiEndpoint)); }
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath AccessControlled context, @QueryParameter String host, @QueryParameter String port, @QueryParameter String credentialsId) { Jenkins jenkins = Jenkins.getInstance(); if ((context == jenkins && !jenkins.hasPermission(Computer.CREATE)) || (context != jenkins && !context.hasPermission(Computer.CONFIGURE))) { return new StandardUsernameListBoxModel() .includeCurrentValue(credentialsId); } try { int portValue = Integer.parseInt(port); return new StandardUsernameListBoxModel() .includeMatchingAs( ACL.SYSTEM, jenkins, StandardUsernameCredentials.class, Collections.singletonList( new HostnamePortRequirement(host, portValue) ), SSHAuthenticator.matcher(Connection.class)) .includeCurrentValue(credentialsId); // always add the current value last in case already present } catch (NumberFormatException ex) { return new StandardUsernameListBoxModel() .includeCurrentValue(credentialsId); } }