本文整理汇总了Java中org.kohsuke.accmod.Restricted类的典型用法代码示例。如果您正苦于以下问题:Java Restricted类的具体用法?Java Restricted怎么用?Java Restricted使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Restricted类属于org.kohsuke.accmod包,在下文中一共展示了Restricted类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doFillCredentialsIdItems
import org.kohsuke.accmod.Restricted; //导入依赖的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.Restricted; //导入依赖的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.Restricted; //导入依赖的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.Restricted; //导入依赖的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: getUrlName
import org.kohsuke.accmod.Restricted; //导入依赖的package包/类
@Restricted(DoNotUse.class)
public @CheckForNull String getUrlName(@Nonnull PhaseExecutionAttachment attachment) {
String urlName = attachment.getUrlName();
if (urlName == null) return null;
if (!attachments.contains(attachment)) throw new IllegalArgumentException(
"Attachment not present in current execution"
);
int cntr = 0;
for (PhaseExecutionAttachment a: attachments) {
if (a.equals(attachment)) break;
if (urlName.equals(a.getUrlName())) {
cntr++;
}
}
if (cntr > 0) {
return "attachment/" + urlName + ':' + cntr;
} else {
return "attachment/" + urlName;
}
}
示例6: getAttachment
import org.kohsuke.accmod.Restricted; //导入依赖的package包/类
@Restricted(DoNotUse.class)
public PhaseExecutionAttachment getAttachment(String urlName) {
int n = 0;
int i = urlName.lastIndexOf(':');
if (i != -1) {
try {
n = Integer.parseInt(urlName.substring(i + 1));
urlName = urlName.substring(0, i - 1);
} catch (NumberFormatException nan) {
// It is not expected that ':' is found in the name, though proceed to fail later as the name will not be found
}
}
int cntr = 0;
for (PhaseExecutionAttachment a: attachments) {
if (!urlName.equals(a.getUrlName())) continue;
if (cntr == n) return a;
cntr++;
}
return null;
}
示例7: getActivity
import org.kohsuke.accmod.Restricted; //导入依赖的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;
}
示例8: getUrl
import org.kohsuke.accmod.Restricted; //导入依赖的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();
}
示例9: onStarted
import org.kohsuke.accmod.Restricted; //导入依赖的package包/类
@Override @Restricted(DoNotUse.class)
public void onStarted(Cloud cloud, Label label, Collection<NodeProvisioner.PlannedNode> plannedNodes) {
BulkChange change = new BulkChange(stats);
try {
boolean changed = false;
for (NodeProvisioner.PlannedNode plannedNode : plannedNodes) {
ProvisioningActivity.Id id = getIdFor(plannedNode);
if (id != null) {
onStarted(id);
changed = true;
}
}
if (changed) {
// Not using change.commit() here as persist handles exceptions already
stats.persist();
}
} finally {
change.abort();
}
}
示例10: getDuration
import org.kohsuke.accmod.Restricted; //导入依赖的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)
;
}
示例11: packageRenameConverting
import org.kohsuke.accmod.Restricted; //导入依赖的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);
}
}
示例12: doHealthcheck
import org.kohsuke.accmod.Restricted; //导入依赖的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));
}
示例13: doHealthcheckOk
import org.kohsuke.accmod.Restricted; //导入依赖的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());
}
示例14: doIndex
import org.kohsuke.accmod.Restricted; //导入依赖的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>");
}
示例15: getPatternStringForSecrets
import org.kohsuke.accmod.Restricted; //导入依赖的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();
}