本文整理了Java中hudson.model.Item.hasPermission()
方法的一些代码示例,展示了Item.hasPermission()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Item.hasPermission()
方法的具体详情如下:
包路径:hudson.model.Item
类名称:Item
方法名:hasPermission
暂无
代码示例来源:origin: jenkinsci/jenkins
private List<StubItem> filterDiscoverableItemListBasedOnPermissions(List<StubItem> r, Item t) {
if (t.task instanceof hudson.model.Item) {
if (!((hudson.model.Item)t.task).hasPermission(hudson.model.Item.READ) && ((hudson.model.Item)t.task).hasPermission(hudson.model.Item.DISCOVER)) {
r.add(new StubItem(new StubTask(t.task)));
}
}
return r;
}
代码示例来源:origin: jenkinsci/jenkins
private static <T extends Item> void getAllItems(final ItemGroup root, Class<T> type, List<T> r) {
List<Item> items = new ArrayList<Item>(((ItemGroup<?>) root).getItems());
// because we add items depth first, we can use the quicker BY_NAME comparison
Collections.sort(items, BY_NAME);
for (Item i : items) {
if (type.isInstance(i)) {
if (i.hasPermission(Item.READ)) {
r.add(type.cast(i));
}
}
if (i instanceof ItemGroup) {
getAllItems((ItemGroup) i, type, r);
}
}
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Gets the {@link Item} object by its full name.
* Full names are like path names, where each name of {@link Item} is
* combined by '/'.
*
* @return
* null if either such {@link Item} doesn't exist under the given full name,
* or it exists but it's no an instance of the given type.
* @throws AccessDeniedException as per {@link ItemGroup#getItem}
*/
public @CheckForNull <T extends Item> T getItemByFullName(String fullName, Class<T> type) throws AccessDeniedException {
StringTokenizer tokens = new StringTokenizer(fullName,"/");
ItemGroup parent = this;
if(!tokens.hasMoreTokens()) return null; // for example, empty full name.
while(true) {
Item item = parent.getItem(tokens.nextToken());
if(!tokens.hasMoreTokens()) {
if(type.isInstance(item))
return type.cast(item);
else
return null;
}
if(!(item instanceof ItemGroup))
return null; // this item can't have any children
if (!item.hasPermission(Item.READ))
return null; // TODO consider DISCOVER
parent = (ItemGroup) item;
}
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Visits an {@link ItemGroup} by visits the member items.
*/
public void onItemGroup(ItemGroup<?> group) {
for (Item i : group.getItems())
if (i.hasPermission(Item.READ))
onItem(i);
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Securely check for the existence of an item before trying to create one with the same name.
* @param parent the folder where we are about to create/rename/move an item
* @param newName the proposed new name
* @param variant if not null, an existing item which we accept could be there
* @throws IllegalArgumentException if there is already something there, which you were supposed to know about
* @throws Failure if there is already something there but you should not be told details
*/
static void verifyItemDoesNotAlreadyExist(@Nonnull ItemGroup<?> parent, @Nonnull String newName, @CheckForNull Item variant) throws IllegalArgumentException, Failure {
Item existing;
try (ACLContext ctxt = ACL.as(ACL.SYSTEM)) {
existing = parent.getItem(newName);
}
if (existing != null && existing != variant) {
if (existing.hasPermission(Item.DISCOVER)) {
String prefix = parent.getFullName();
throw new IllegalArgumentException((prefix.isEmpty() ? "" : prefix + "/") + newName + " already exists");
} else {
// Cannot hide its existence, so at least be as vague as possible.
throw new Failure("");
}
}
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Used by {@code <f:password/>} so that we send an encrypted value to the client.
*/
public String getPasswordValue(Object o) {
if (o==null) return null;
if (o instanceof Secret) {
StaplerRequest req = Stapler.getCurrentRequest();
if (req != null) {
Item item = req.findAncestorObject(Item.class);
if (item != null && !item.hasPermission(Item.CONFIGURE)) {
return "********";
}
}
return ((Secret) o).getEncryptedValue();
}
if (getIsUnitTest() && !o.equals(PasswordParameterDefinition.DEFAULT_VALUE)) {
throw new SecurityException("attempted to render plaintext ‘" + o + "’ in password field; use a getter of type Secret instead");
}
return o.toString();
}
代码示例来源:origin: jenkinsci/jenkins
ItemGroup g = (ItemGroup) ctx;
Item i = g.getItem(s);
if (i==null || !i.hasPermission(Item.READ)) { // TODO consider DISCOVER
代码示例来源:origin: jenkinsci/jenkins
if (!item.hasPermission(auth, Item.BUILD)) {
return FormValidation.error(Messages.BuildTrigger_you_have_no_permission_to_build_(projectName));
代码示例来源:origin: jenkinsci/jenkins
boolean canDiscoverTheItem = itemBySystemUser.hasPermission(userAuth, Item.DISCOVER);
if (canDiscoverTheItem) {
ItemGroup<?> current = itemBySystemUser.getParent();
final Item i = (Item) current;
current = i.getParent();
if (!i.hasPermission(userAuth, Item.READ)) {
canDiscoverTheItem = false;
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
private List<StubItem> filterDiscoverableItemListBasedOnPermissions(List<StubItem> r, Item t) {
if (t.task instanceof hudson.model.Item) {
if (!((hudson.model.Item)t.task).hasPermission(hudson.model.Item.READ) && ((hudson.model.Item)t.task).hasPermission(hudson.model.Item.DISCOVER)) {
r.add(new StubItem(new StubTask(t.task)));
}
}
return r;
}
代码示例来源:origin: org.jenkins-ci.plugins/cloudbees-folder
/**
* {@inheritDoc}
*/
@Override
public String getIconClassName() {
return !item.hasPermission(RELOCATE) || ui == null || !ui.isAvailable(item) ? null : ui.getIconClassName();
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
/**
* Visits an {@link ItemGroup} by visits the member items.
*/
public void onItemGroup(ItemGroup<?> group) {
for (Item i : group.getItems())
if (i.hasPermission(Item.READ))
onItem(i);
}
代码示例来源:origin: org.jenkins-ci.plugins/cloudbees-folder
/**
* {@inheritDoc}
*/
@Override
public String getIconFileName() {
return !item.hasPermission(RELOCATE) || ui == null || !ui.isAvailable(item) ? null : ui.getIconFileName();
}
代码示例来源:origin: jenkinsci/cloudbees-folder-plugin
/**
* {@inheritDoc}
*/
@Override
public String getIconFileName() {
return !item.hasPermission(RELOCATE) || ui == null || !ui.isAvailable(item) ? null : ui.getIconFileName();
}
代码示例来源:origin: jenkinsci/cloudbees-folder-plugin
/**
* {@inheritDoc}
*/
@Override
public String getIconClassName() {
return !item.hasPermission(RELOCATE) || ui == null || !ui.isAvailable(item) ? null : ui.getIconClassName();
}
代码示例来源:origin: jenkinsci/subversion-plugin
/**
* Validate the value for a remote (repository) location.
*/
@RequirePOST
public FormValidation doCheckCredentialsId(StaplerRequest req, @AncestorInPath Item context,
@QueryParameter String remote, @QueryParameter String value) {
// Test the connection only if we may use the credentials (cf. hudson.plugins.git.UserRemoteConfig.DescriptorImpl.doCheckUrl)
if (context == null && !Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER) ||
context != null && !context.hasPermission(CredentialsProvider.USE_ITEM)) {
return FormValidation.ok();
}
return checkCredentialsId(req, context, remote, value);
}
代码示例来源:origin: jenkinsci/subversion-plugin
@RequirePOST
public FormValidation doCheckCredentialsId(StaplerRequest req, @AncestorInPath Item context, @QueryParameter String tagsDir, @QueryParameter String value) {
if (context == null || !context.hasPermission(CredentialsProvider.USE_ITEM)) {
return FormValidation.ok();
}
return Jenkins.getInstance().getDescriptorByType(
SubversionSCM.ModuleLocation.DescriptorImpl.class).checkCredentialsId(req, context, tagsDir, value);
}
代码示例来源:origin: jenkinsci/subversion-plugin
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Item context, @QueryParameter String tagsDir) {
if (context == null || !context.hasPermission(Item.EXTENDED_READ)) {
return new StandardListBoxModel();
}
return Jenkins.getInstance().getDescriptorByType(
SubversionSCM.ModuleLocation.DescriptorImpl.class).fillCredentialsIdItems(context, tagsDir);
}
代码示例来源:origin: jenkinsci/subversion-plugin
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Item context, @QueryParameter String remote) {
if (context == null && !Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER) ||
context != null && !context.hasPermission(Item.EXTENDED_READ)) {
return new StandardListBoxModel();
}
return fillCredentialsIdItems(context, remote);
}
代码示例来源:origin: org.jenkins-ci.plugins/github-branch-source
public ListBoxModel doFillCredentialsIdItems(@CheckForNull @AncestorInPath Item context,
@QueryParameter String apiUri,
@QueryParameter String credentialsId) {
if (context == null
? !Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER)
: !context.hasPermission(Item.EXTENDED_READ)) {
return new StandardListBoxModel().includeCurrentValue(credentialsId);
}
return Connector.listScanCredentials(context, apiUri);
}
内容来源于网络,如有侵权,请联系作者删除!