private boolean hasAccessToCredentialsMetadata(SCMSourceOwner owner){ if (owner == null){ return Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER); } return owner.hasPermission(Item.EXTENDED_READ); }
if (!context.hasPermission(Item.EXTENDED_READ) && !context.hasPermission(CredentialsProvider.USE_ITEM)) { return FormValidation.ok();
if (!context.hasPermission(Item.EXTENDED_READ) && !context.hasPermission(CredentialsProvider.USE_ITEM)) { return FormValidation.ok();
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath SCMSourceOwner 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.includeEmptyValue(); result.includeMatchingAs( context instanceof Queue.Task ? Tasks.getDefaultAuthenticationOf((Queue.Task) context) : ACL.SYSTEM, context, StandardCredentials.class, URIRequirementBuilder.fromUri(serverUrl).build(), AuthenticationTokens.matcher(GiteaAuth.class) ); return result; }
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath SCMSourceOwner 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.includeEmptyValue(); result.includeMatchingAs( context instanceof Queue.Task ? Tasks.getDefaultAuthenticationOf((Queue.Task) context) : ACL.SYSTEM, context, StandardCredentials.class, URIRequirementBuilder.fromUri(serverUrl).build(), AuthenticationTokens.matcher(GiteaAuth.class) ); return result; }
@Restricted(NoExternalUse.class) public ListBoxModel doFillCheckoutCredentialsIdItems(@AncestorInPath SCMSourceOwner context, @QueryParameter String connectionName, @QueryParameter String checkoutCredentialsId) { if (context == null && !Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER) || context != null && !context.hasPermission(Item.EXTENDED_READ)) { return new StandardListBoxModel().includeCurrentValue(checkoutCredentialsId); } StandardListBoxModel result = new StandardListBoxModel(); result.add("- anonymous -", CHECKOUT_CREDENTIALS_ANONYMOUS); return result.includeMatchingAs( context instanceof Queue.Task ? Tasks.getDefaultAuthenticationOf((Queue.Task) context) : ACL.SYSTEM, context, StandardUsernameCredentials.class, SettingsUtils.gitLabConnectionRequirements(connectionName), GitClient.CREDENTIALS_MATCHER ); }
public ListBoxModel doFillServerUrlItems(@AncestorInPath SCMSourceOwner context, @QueryParameter String serverUrl) { if (context == null) { if (!Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER)) { // must have admin if you want the list without a context ListBoxModel result = new ListBoxModel(); result.add(serverUrl); return result; } } else { if (!context.hasPermission(Item.EXTENDED_READ)) { // must be able to read the configuration the list ListBoxModel result = new ListBoxModel(); result.add(serverUrl); return result; } } return GiteaServers.get().getServerItems(); }
public ListBoxModel doFillServerUrlItems(@AncestorInPath SCMSourceOwner context, @QueryParameter String serverUrl) { if (context == null) { if (!Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER)) { // must have admin if you want the list without a context ListBoxModel result = new ListBoxModel(); result.add(serverUrl); return result; } } else { if (!context.hasPermission(Item.EXTENDED_READ)) { // must be able to read the configuration the list ListBoxModel result = new ListBoxModel(); result.add(serverUrl); return result; } } return GiteaServers.get().getServerItems(); }
if (!context.hasPermission(Item.EXTENDED_READ) && !context.hasPermission(CredentialsProvider.USE_ITEM)) {