本文整理汇总了Java中org.kohsuke.accmod.restrictions.NoExternalUse类的典型用法代码示例。如果您正苦于以下问题:Java NoExternalUse类的具体用法?Java NoExternalUse怎么用?Java NoExternalUse使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NoExternalUse类属于org.kohsuke.accmod.restrictions包,在下文中一共展示了NoExternalUse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doFillCredentialsIdItems
import org.kohsuke.accmod.restrictions.NoExternalUse; //导入依赖的package包/类
/**
* Stapler form completion.
*
* @param serverUrl the server URL.
* @return the available credentials.
*/
@Restricted(NoExternalUse.class) // stapler
@SuppressWarnings("unused")
public ListBoxModel doFillCredentialsIdItems(@QueryParameter String serverUrl) {
Jenkins.getActiveInstance().checkPermission(Jenkins.ADMINISTER);
StandardListBoxModel result = new StandardListBoxModel();
serverUrl = GiteaServers.normalizeServerUrl(serverUrl);
result.includeMatchingAs(
ACL.SYSTEM,
Jenkins.getActiveInstance(),
StandardCredentials.class,
URIRequirementBuilder.fromUri(serverUrl).build(),
AuthenticationTokens.matcher(GiteaAuth.class)
);
return result;
}
示例2: doCheckToken
import org.kohsuke.accmod.restrictions.NoExternalUse; //导入依赖的package包/类
/**
* Sanity check for a Gitea access token.
*
* @param value the token.
* @return the resulst of the sanity check.
*/
@Restricted(NoExternalUse.class) // stapler
@SuppressWarnings("unused") // stapler
public FormValidation doCheckToken(@QueryParameter String value) {
Secret secret = Secret.fromString(value);
if (secret == null) {
return FormValidation.error(Messages.PersonalAccessTokenImpl_tokenRequired());
}
if (StringUtils.equals(value, secret.getPlainText())) {
if (value.length() != 40) {
return FormValidation.error(Messages.PersonalAccessTokenImpl_tokenWrongLength());
}
} else if (secret.getPlainText().length() != 40) {
return FormValidation.warning(Messages.PersonalAccessTokenImpl_tokenWrongLength());
}
return FormValidation.ok();
}
示例3: doFillCheckoutCredentialsIdItems
import org.kohsuke.accmod.restrictions.NoExternalUse; //导入依赖的package包/类
@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
);
}
示例4: getBrowse
import org.kohsuke.accmod.restrictions.NoExternalUse; //导入依赖的package包/类
/**
* Method accessed by the Stapler framework when the following url is accessed:
* <i>JENKINS_ROOT_URL/exws/browse/workspaceId/</i>
*
* @param workspaceId the workspace's unique id
* @return the workspace whose id matches the given input id, or {@link NoFingerprintMatch} if fingerprint is not found
* @throws IOException if fingerprint load operation fails
* @throws IllegalArgumentException if {@link WorkspaceBrowserFacet} is not registered for the matching fingerprint
*/
@Restricted(NoExternalUse.class)
@SuppressWarnings("unused")
@Nonnull
public Object getBrowse(String workspaceId) throws IOException {
Fingerprint fingerprint = Jenkins.getActiveInstance()._getFingerprint(workspaceId);
if (fingerprint == null) {
return new NoFingerprintMatch(workspaceId);
}
WorkspaceBrowserFacet facet = fingerprint.getFacet(WorkspaceBrowserFacet.class);
if (facet == null) {
throw new IllegalArgumentException("Couldn't find the Fingerprint Facet that holds the Workspace metadata");
}
return facet.getWorkspace();
}
示例5: getActivity
import org.kohsuke.accmod.restrictions.NoExternalUse; //导入依赖的package包/类
@Restricted(NoExternalUse.class) // view only
public ProvisioningActivity getActivity(@Nonnull String hashString) {
int hash;
try {
hash = Integer.parseInt(hashString);
} catch (NumberFormatException nan) {
return null;
}
for (ProvisioningActivity activity : getActivities()) {
if (activity.getId().getFingerprint() == hash) {
return activity;
}
}
return null;
}
示例6: getUrl
import org.kohsuke.accmod.restrictions.NoExternalUse; //导入依赖的package包/类
@Restricted(NoExternalUse.class) // view only
public @CheckForNull String getUrl(
@Nonnull ProvisioningActivity activity,
@Nonnull PhaseExecution phaseExecution,
@Nonnull PhaseExecutionAttachment attachment
) {
activity.getClass(); phaseExecution.getClass(); attachment.getClass();
// No UI
if (attachment.getUrlName() == null) return null;
StringBuilder url = new StringBuilder("/cloud-stats/");
url.append("activity/").append(activity.getId().getFingerprint()).append('/');
url.append("phase/").append(phaseExecution.getPhase().toString()).append('/');
url.append(phaseExecution.getUrlName(attachment)).append('/');
return url.toString();
}
示例7: getDuration
import org.kohsuke.accmod.restrictions.NoExternalUse; //导入依赖的package包/类
/**
* Get duration of the activity phase.
*
* @return Positive integer in case the phase is completed, negative in case it is in progress
*/
@Restricted(NoExternalUse.class) // Stapler only
public long getDuration(@Nonnull PhaseExecution execution) {
Phase phase = execution.getPhase();
if (phase == Phase.COMPLETED) throw new IllegalArgumentException();
// Find any later nonnull execution
PhaseExecution next = null;
for (Phase p: Phase.values()) {
if (p.ordinal() <= phase.ordinal()) continue;
next = getPhaseExecution(p);
if (next != null) break;
}
long started = execution.getStartedTimestamp();
return next != null
? next.getStartedTimestamp() - started
: -(System.currentTimeMillis() - started)
;
}
示例8: packageRenameConverting
import org.kohsuke.accmod.restrictions.NoExternalUse; //导入依赖的package包/类
@Initializer(before = InitMilestone.JOB_LOADED)
@Restricted(NoExternalUse.class)
public static void packageRenameConverting() {
for(XStream2 xs : Arrays.asList(Items.XSTREAM2, Run.XSTREAM2, Jenkins.XSTREAM2, getFingerprintXStream())) {
xs.addCompatibilityAlias("org.jenkinsci.plugins.dockerhub.notification.DockerHubTrigger",
DockerHubTrigger.class);
xs.addCompatibilityAlias("org.jenkinsci.plugins.dockerhub.notification.DockerHubWebHookCause",
DockerHubWebHookCause.class);
xs.addCompatibilityAlias("org.jenkinsci.plugins.dockerhub.notification.DockerPullImageBuilder",
DockerPullImageBuilder.class);
//TODO no back-compat tests for the column and filter
xs.addCompatibilityAlias("org.jenkinsci.plugins.dockerhub.notification.TriggerListViewColumn",
TriggerListViewColumn.class);
xs.addCompatibilityAlias("org.jenkinsci.plugins.dockerhub.notification.TriggerViewFilter",
TriggerViewFilter.class);
//The TriggerOption extension point has also changed package name and will not be backwards compatible API
xs.addCompatibilityAlias("org.jenkinsci.plugins.dockerhub.notification.opt.impl.TriggerForAllUsedInJob",
TriggerForAllUsedInJob.class);
xs.addCompatibilityAlias("org.jenkinsci.plugins.dockerhub.notification.opt.impl.TriggerOnSpecifiedImageNames",
TriggerOnSpecifiedImageNames.class);
xs.addCompatibilityAlias("org.jenkinsci.plugins.dockerhub.notification.TriggerStore$TriggerEntry",
TriggerStore.TriggerEntry.class);
xs.addCompatibilityAlias("org.jenkinsci.plugins.dockerhub.notification.TriggerStore$TriggerEntry$RunEntry",
TriggerStore.TriggerEntry.RunEntry.class);
}
}
示例9: doHealthcheck
import org.kohsuke.accmod.restrictions.NoExternalUse; //导入依赖的package包/类
/**
* Binds the health checks to the CORS aware URL {@code /metrics/healthcheck} where the metrics access key is
* provided in the form field {@code key} or an {@code Authorization: Jenkins-Metrics-Key {key}} header
*
* @param req the request
* @param key the key from the form field.
* @return the {@link HttpResponse}
* @throws IllegalAccessException if the access attempt is invalid.
*/
@SuppressWarnings("unused") // stapler binding
@Restricted(NoExternalUse.class) // stapler binding
public HttpResponse doHealthcheck(StaplerRequest req, @QueryParameter("key") String key)
throws IllegalAccessException {
requireCorrectMethod(req);
if (StringUtils.isBlank(key)) {
key = getKeyFromAuthorizationHeader(req);
}
Metrics.checkAccessKeyHealthCheck(key);
long ifModifiedSince = req.getDateHeader("If-Modified-Since");
long maxAge = getCacheControlMaxAge(req);
Metrics.HealthCheckData data = Metrics.getHealthCheckData();
if (data == null || (maxAge != -1 && data.getLastModified() + maxAge < System.currentTimeMillis())) {
data = new Metrics.HealthCheckData(Metrics.healthCheckRegistry().runHealthChecks());
} else if (ifModifiedSince != -1 && data.getLastModified() < ifModifiedSince) {
return Metrics.cors(key, HttpResponses.status(HttpServletResponse.SC_NOT_MODIFIED));
}
return Metrics.cors(key, new HealthCheckResponse(data));
}
示例10: doHealthcheckOk
import org.kohsuke.accmod.restrictions.NoExternalUse; //导入依赖的package包/类
/**
* Condense the health check into one bit of information
* for frontend reverse proxies like haproxy.
*
* Other health check calls requires authentication, which
* is not suitable for the haproxy use. But this endpoint
* only exposes one bit information, it's deemed OK to be exposed
* unsecurely.
*
* return status 200 if everything is OK, 503 (service unavailable) otherwise
*
* @param req the request
* @return the HTTP response
*/
@SuppressWarnings("unused") // stapler binding
@Restricted(NoExternalUse.class) // stapler binding
public HttpResponse doHealthcheckOk(StaplerRequest req) {
long ifModifiedSince = req.getDateHeader("If-Modified-Since");
long maxAge = getCacheControlMaxAge(req);
Metrics.HealthCheckData data = Metrics.getHealthCheckData();
if (data == null || (maxAge != -1 && data.getLastModified() + maxAge < System.currentTimeMillis())) {
data = new Metrics.HealthCheckData(Metrics.healthCheckRegistry().runHealthChecks());
} else if (ifModifiedSince != -1 && data.getLastModified() < ifModifiedSince) {
return HttpResponses.status(HttpServletResponse.SC_NOT_MODIFIED);
}
for (HealthCheck.Result result : data.getResults().values()) {
if (!result.isHealthy()) {
return new StatusResponse(HttpServletResponse.SC_SERVICE_UNAVAILABLE, data.getLastModified(),
data.getExpires());
}
}
return new StatusResponse(HttpServletResponse.SC_OK, data.getLastModified(), data.getExpires());
}
示例11: doIndex
import org.kohsuke.accmod.restrictions.NoExternalUse; //导入依赖的package包/类
/**
* Web binding for {@literal /}
*
* @return the response
*/
@Restricted(NoExternalUse.class) // only for use by stapler web binding
public HttpResponse doIndex() {
return HttpResponses
.html("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\n" +
" \"http://www.w3.org/TR/html4/loose.dtd\">\n" +
"<html>\n" +
"<head>\n" +
" <title>Metrics</title>\n" +
"</head>\n" +
"<body>\n" +
" <h1>Operational Menu</h1>\n" +
" <ul>\n" +
" <li><a href=\"./metrics?pretty=true\">Metrics</a></li>\n" +
" <li><a href=\"./ping\">Ping</a></li>\n" +
" <li><a href=\"./threads\">Threads</a></li>\n" +
" <li><a href=\"./healthcheck?pretty=true\">Healthcheck</a></li>\n" +
" </ul>\n" +
"</body>\n" +
"</html>");
}
示例12: getPatternStringForSecrets
import org.kohsuke.accmod.restrictions.NoExternalUse; //导入依赖的package包/类
/**
* Utility method for turning a collection of secret strings into a single {@link String} for pattern compilation.
* @param secrets A collection of secret strings
* @return A {@link String} generated from that collection.
*/
@Restricted(NoExternalUse.class)
public static String getPatternStringForSecrets(Collection<String> secrets) {
StringBuilder b = new StringBuilder();
List<String> sortedByLength = new ArrayList<String>(secrets);
Collections.sort(sortedByLength, stringLengthComparator);
for (String secret : sortedByLength) {
if (!secret.isEmpty()) {
if (b.length() > 0) {
b.append('|');
}
b.append(Pattern.quote(secret));
}
}
return b.toString();
}
示例13: doFillModeItems
import org.kohsuke.accmod.restrictions.NoExternalUse; //导入依赖的package包/类
/**
* Form completion.
*
* @return the mode options.
*/
@Restricted(NoExternalUse.class)
@SuppressWarnings("unused") // stapler form binding
public ListBoxModel doFillModeItems() {
ListBoxModel result = new ListBoxModel();
result.add(Messages.WebhookRegistrationTrait_disableHook(), WebhookRegistration.DISABLE.toString());
result.add(Messages.WebhookRegistrationTrait_useItemHook(), WebhookRegistration.ITEM.toString());
return result;
}
示例14: doFillCredentialsIdItems
import org.kohsuke.accmod.restrictions.NoExternalUse; //导入依赖的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;
}
示例15: doCheckCredentialsId
import org.kohsuke.accmod.restrictions.NoExternalUse; //导入依赖的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());
}