本文整理匯總了Java中hudson.security.ACL類的典型用法代碼示例。如果您正苦於以下問題:Java ACL類的具體用法?Java ACL怎麽用?Java ACL使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ACL類屬於hudson.security包,在下文中一共展示了ACL類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getRun
import hudson.security.ACL; //導入依賴的package包/類
@CheckForNull
public Run<?, ?> getRun() {
if (StringUtils.isBlank(buildId)) {
return null;
}
final Job<?, ?> job = getJob();
if (job != null) {
SecurityContext old = ACL.impersonate(ACL.SYSTEM);
try {
return job.getBuild(buildId);
} catch (Exception e) {
logger.log(Level.WARNING, "Unable to retrieve run " + jobName + ":" + buildId, e);
} finally {
SecurityContextHolder.setContext(old);
}
}
return null;
}
示例2: doFillCredentialsIdItems
import hudson.security.ACL; //導入依賴的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;
}
示例3: doFillCredentialsIdItems
import hudson.security.ACL; //導入依賴的package包/類
public static ListBoxModel doFillCredentialsIdItems(String credentialsId) {
if (credentialsId == null) {
credentialsId = "";
}
if (!Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER)) {
// Important! Otherwise you expose credentials metadata to random
// web requests.
return new StandardListBoxModel()
.includeCurrentValue(credentialsId);
}
return new StandardListBoxModel()
.includeEmptyValue()
.includeAs(ACL.SYSTEM, Jenkins.getInstance(),
OpenShiftTokenCredentials.class)
// .includeAs(ACL.SYSTEM, Jenkins.getInstance(),
// StandardUsernamePasswordCredentials.class)
// .includeAs(ACL.SYSTEM, Jenkins.getInstance(),
// StandardCertificateCredentials.class)
// TODO: Make own type for token or use the existing token
// generator auth type used by sync plugin? or kubernetes?
.includeCurrentValue(credentialsId);
}
示例4: doFillPrincipalCredentialIdItems
import hudson.security.ACL; //導入依賴的package包/類
public ListBoxModel doFillPrincipalCredentialIdItems(
@AncestorInPath Item item,
@QueryParameter String credentialsId) {
StandardListBoxModel result = new StandardListBoxModel();
if (item == null) {
if (!Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER)) {
return result.includeCurrentValue(credentialsId);
}
} else {
if (!item.hasPermission(Item.EXTENDED_READ)
&& !item.hasPermission(CredentialsProvider.USE_ITEM)) {
return result.includeCurrentValue(credentialsId);
}
}
List<AzureCredentials> creds = CredentialsProvider.lookupCredentials(AzureCredentials.class, item, ACL.SYSTEM, Collections.<DomainRequirement>emptyList());
for (AzureCredentials cred
:
creds) {
result.add(cred.getId());
}
return result.includeEmptyValue()
.includeCurrentValue(credentialsId);
}
示例5: abortShouldNotRetry
import hudson.security.ACL; //導入依賴的package包/類
@Issue("JENKINS-41276")
@Test
public void abortShouldNotRetry() throws Exception {
r.jenkins.setSecurityRealm(r.createDummySecurityRealm());
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition(
"int count = 0; retry(3) { echo 'trying '+(count++); semaphore 'start'; echo 'NotHere' } echo 'NotHere'", true));
final WorkflowRun b = p.scheduleBuild2(0).waitForStart();
SemaphoreStep.waitForStart("start/1", b);
ACL.impersonate(User.get("dev").impersonate(), new Runnable() {
@Override public void run() {
b.getExecutor().doStop();
}
});
r.assertBuildStatus(Result.ABORTED, r.waitForCompletion(b));
r.assertLogContains("trying 0", b);
r.assertLogContains("Aborted by dev", b);
r.assertLogNotContains("trying 1", b);
r.assertLogNotContains("trying 2", b);
r.assertLogNotContains("NotHere", b);
}
示例6: doFillMirrorgateCredentialsIdItems
import hudson.security.ACL; //導入依賴的package包/類
public ListBoxModel doFillMirrorgateCredentialsIdItems(
@AncestorInPath Item item,
@QueryParameter("mirrorgateCredentialsId") String credentialsId) {
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()
.includeAs(ACL.SYSTEM, item, StandardUsernamePasswordCredentials.class);
}
示例7: doFillCredentialsIdItems
import hudson.security.ACL; //導入依賴的package包/類
public ListBoxModel doFillCredentialsIdItems(
@AncestorInPath Item context,
@QueryParameter String remote,
@QueryParameter String credentialsId) {
if (context == null && !Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER)
|| context != null && !context.hasPermission(Item.EXTENDED_READ)) {
return new StandardListBoxModel().includeCurrentValue(credentialsId);
}
return new StandardListBoxModel()
.includeEmptyValue()
.includeMatchingAs(
context instanceof Queue.Task
? Tasks.getAuthenticationOf((Queue.Task) context)
: ACL.SYSTEM,
context,
StandardUsernameCredentials.class,
URIRequirementBuilder.fromUri(remote).build(),
GitClient.CREDENTIALS_MATCHER)
.includeCurrentValue(credentialsId);
}
示例8: doFillCheckoutCredentialsIdItems
import hudson.security.ACL; //導入依賴的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
);
}
示例9: doFillCredentialsIdItems
import hudson.security.ACL; //導入依賴的package包/類
/**
* Fills in the Login Credentials selection box with applicable connections.
*
* @param context
* filter for login credentials
* @param credentialsId
* existing login credentials; can be null
* @param project
* the Jenkins project
*
* @return login credentials selection
*/
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Jenkins context, @QueryParameter String credentialsId,
@AncestorInPath Item project)
{
List<StandardUsernamePasswordCredentials> creds = CredentialsProvider.lookupCredentials(
StandardUsernamePasswordCredentials.class, project, ACL.SYSTEM,
Collections.<DomainRequirement> emptyList());
ListBoxModel model = new ListBoxModel();
model.add(new Option(StringUtils.EMPTY, StringUtils.EMPTY, false));
for (StandardUsernamePasswordCredentials c : creds)
{
boolean isSelected = false;
if (credentialsId != null)
{
isSelected = credentialsId.matches(c.getId());
}
String description = Util.fixEmptyAndTrim(c.getDescription());
model.add(new Option(c.getUsername() + (description != null ? " (" + description + ')' : StringUtils.EMPTY), //$NON-NLS-1$
c.getId(), isSelected));
}
return model;
}
示例10: doFillCredentialsIdItems
import hudson.security.ACL; //導入依賴的package包/類
/**
* Fills in the Login Credentials selection box with applicable Jenkins credentials.
*
* @param context
* filter for credentials
* @param credentialsId
* existing login credentials; can be null
* @param project
* the Jenkins project
*
* @return credential selections
*/
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Jenkins context, @QueryParameter String credentialsId, @AncestorInPath Item project)
{
List<StandardUsernamePasswordCredentials> creds = CredentialsProvider.lookupCredentials(
StandardUsernamePasswordCredentials.class, project, ACL.SYSTEM,
Collections.<DomainRequirement> emptyList());
StandardListBoxModel model = new StandardListBoxModel();
model.add(new Option(StringUtils.EMPTY, StringUtils.EMPTY, false));
for (StandardUsernamePasswordCredentials c : creds)
{
boolean isSelected = false;
if (credentialsId != null)
{
isSelected = credentialsId.matches(c.getId());
}
String description = Util.fixEmptyAndTrim(c.getDescription());
model.add(new Option(c.getUsername() + (description != null ? " (" + description + ')' : StringUtils.EMPTY), //$NON-NLS-1$
c.getId(), isSelected));
}
return model;
}
示例11: getLoginInformation
import hudson.security.ACL; //導入依賴的package包/類
/**
* Retrieves login information given a credential ID.
*
* @param project
* the Jenkins project
*
* @return a Jenkins credential with login information
*/
protected StandardUsernamePasswordCredentials getLoginInformation(Item project)
{
StandardUsernamePasswordCredentials credential = null;
List<StandardUsernamePasswordCredentials> credentials = CredentialsProvider.lookupCredentials(
StandardUsernamePasswordCredentials.class, project, ACL.SYSTEM, Collections.<DomainRequirement> emptyList());
IdMatcher matcher = new IdMatcher(getCredentialsId());
for (StandardUsernamePasswordCredentials c : credentials)
{
if (matcher.matches(c))
{
credential = c;
}
}
return credential;
}
示例12: getLoginInformation
import hudson.security.ACL; //導入依賴的package包/類
/**
* Retrieves login information given a credential ID
*
* @param project
* the Jenkins project
*
* @return a Jenkins credential with login information
*/
protected StandardUsernamePasswordCredentials getLoginInformation(Item project)
{
StandardUsernamePasswordCredentials credential = null;
List<StandardUsernamePasswordCredentials> credentials = CredentialsProvider.lookupCredentials(
StandardUsernamePasswordCredentials.class, project, ACL.SYSTEM, Collections.<DomainRequirement> emptyList());
IdMatcher matcher = new IdMatcher(getCredentialsId());
for (StandardUsernamePasswordCredentials c : credentials)
{
if (matcher.matches(c))
{
credential = c;
}
}
return credential;
}
示例13: getCurrentToken
import hudson.security.ACL; //導入依賴的package包/類
public static String getCurrentToken() {
String credentialsId = GlobalPluginConfiguration.get()
.getCredentialsId();
if (credentialsId.equals("")) {
return "";
}
OpenShiftToken token = CredentialsMatchers.firstOrNull(
CredentialsProvider.lookupCredentials(OpenShiftToken.class,
Jenkins.getActiveInstance(), ACL.SYSTEM,
Collections.<DomainRequirement> emptyList()),
CredentialsMatchers.withId(credentialsId));
if (token != null) {
return token.getToken();
}
return "";
}
示例14: terminateRun
import hudson.security.ACL; //導入依賴的package包/類
private static void terminateRun(final WorkflowRun run) {
ACL.impersonate(ACL.SYSTEM, new NotReallyRoleSensitiveCallable<Void, RuntimeException>() {
@Override
public Void call() throws RuntimeException {
run.doTerm();
Timer.get().schedule(new SafeTimerTask() {
@Override
public void doRun() {
ACL.impersonate(ACL.SYSTEM, new NotReallyRoleSensitiveCallable<Void, RuntimeException>() {
@Override
public Void call() throws RuntimeException {
run.doKill();
return null;
}
});
}
}, 5, TimeUnit.SECONDS);
return null;
}
});
}
示例15: cancelQueuedBuild
import hudson.security.ACL; //導入依賴的package包/類
@SuppressFBWarnings("SE_BAD_FIELD")
public static boolean cancelQueuedBuild(WorkflowJob job, Build build) {
String buildUid = build.getMetadata().getUid();
final Queue buildQueue = Jenkins.getActiveInstance().getQueue();
for (final Queue.Item item : buildQueue.getItems()) {
for (Cause cause : item.getCauses()) {
if (cause instanceof BuildCause && ((BuildCause) cause).getUid().equals(buildUid)) {
return ACL.impersonate(ACL.SYSTEM, new NotReallyRoleSensitiveCallable<Boolean, RuntimeException>() {
@Override
public Boolean call() throws RuntimeException {
buildQueue.cancel(item);
return true;
}
});
}
}
}
return cancelNotYetStartedBuild(job, build);
}