@Override public boolean hasPermission(Authentication a, Permission permission) { return CredentialsStore.this.hasPermission(a, permission); } };
@Override public boolean hasPermission(Authentication a, Permission permission) { return CredentialsStore.this.hasPermission(a, permission); } };
/** * Exposes if this store is enabled for the current user. * * @return {@code true} if the current user can add credentials to this store. */ public boolean isEnabled() { return url != null && store.hasPermission(CREATE) && !store.getCredentialsDescriptors() .isEmpty(); }
/** * Exposes if this store is enabled for the current user. * * @return {@code true} if the current user can add credentials to this store. */ public boolean isEnabled() { return url != null && store.hasPermission(CREATE) && !store.getCredentialsDescriptors() .isEmpty(); }
@Override public boolean hasPermission(@Nonnull Authentication a, @Nonnull Permission permission) { if (accessControlled.getACL().hasPermission(a, permission)) { for (CredentialsStore s : getLocalStores()) { if (s.hasPermission(a, permission)) { return true; } } } return false; } };
/** * Checks if the current security principal has this permission. * * @return {@code false} if the user doesn't have the permission. */ public final boolean hasPermission(@NonNull Permission p) { return hasPermission(Jenkins.getAuthentication(), p); }
@Override public boolean hasPermission(@Nonnull Authentication a, @Nonnull Permission permission) { if (accessControlled.getACL().hasPermission(a, permission)) { for (CredentialsStore s : getLocalStores()) { if (s.hasPermission(a, permission)) { return true; } } } return false; } };
/** * Checks if the current security principal has this permission. * * @return {@code false} if the user doesn't have the permission. */ public final boolean hasPermission(@NonNull Permission p) { return hasPermission(Jenkins.getAuthentication(), p); }
/** * Exposes the {@link CredentialsStore} instances available to the {@link #getContext()}. * * @return the {@link CredentialsStore} instances available to the {@link #getContext()}. */ @NonNull public List<CredentialsStore> getLocalStores() { List<CredentialsStore> result = new ArrayList<CredentialsStore>(); for (CredentialsStore s : CredentialsProvider.lookupStores(getContext())) { if (context == s.getContext() && s.hasPermission(CredentialsProvider.VIEW)) { result.add(s); } } return result; }
/** * Exposes the {@link CredentialsStore} instances available to the {@link #getContext()}. * * @return the {@link CredentialsStore} instances available to the {@link #getContext()}. */ @NonNull public List<CredentialsStore> getParentStores() { List<CredentialsStore> result = new ArrayList<CredentialsStore>(); for (CredentialsStore s : CredentialsProvider.lookupStores(getContext())) { if (context != s.getContext() && s.hasPermission(CredentialsProvider.VIEW)) { result.add(s); } } return result; }
/** * Exposes the {@link CredentialsStore} instances available to the {@link #getContext()}. * * @return the {@link CredentialsStore} instances available to the {@link #getContext()}. */ @NonNull public List<CredentialsStore> getLocalStores() { List<CredentialsStore> result = new ArrayList<CredentialsStore>(); for (CredentialsStore s : CredentialsProvider.lookupStores(getContext())) { if (context == s.getContext() && s.hasPermission(CredentialsProvider.VIEW)) { result.add(s); } } return result; }
/** * Exposes the {@link CredentialsStore} instances available to the {@link #getContext()}. * * @return the {@link CredentialsStore} instances available to the {@link #getContext()}. */ @NonNull public List<CredentialsStore> getParentStores() { List<CredentialsStore> result = new ArrayList<CredentialsStore>(); for (CredentialsStore s : CredentialsProvider.lookupStores(getContext())) { if (context != s.getContext() && s.hasPermission(CredentialsProvider.VIEW)) { result.add(s); } } return result; }
/** * Checks if the current security principal has this permission. * <p> * Note: This is just a convenience function. * </p> * * @throws org.acegisecurity.AccessDeniedException if the user doesn't have the permission. */ public final void checkPermission(@NonNull Permission p) { Authentication a = Jenkins.getAuthentication(); if (!hasPermission(a, p)) { throw new AccessDeniedException2(a, p); } }
/** * Checks if the current security principal has this permission. * <p> * Note: This is just a convenience function. * </p> * * @throws org.acegisecurity.AccessDeniedException if the user doesn't have the permission. */ public final void checkPermission(@NonNull Permission p) { Authentication a = Jenkins.getAuthentication(); if (!hasPermission(a, p)) { throw new AccessDeniedException2(a, p); } }
/** * Exposes the {@link #getLocalStores()} {@link CredentialsStore#getStoreAction()}. * * @return the {@link #getLocalStores()} {@link CredentialsStore#getStoreAction()}. */ @NonNull @SuppressWarnings("unused") // Jelly EL public List<CredentialsStoreAction> getStoreActions() { List<CredentialsStoreAction> result = new ArrayList<CredentialsStoreAction>(); for (final CredentialsStore s : CredentialsProvider.lookupStores(getContext())) { if (context == s.getContext() && s.hasPermission(CredentialsProvider.VIEW)) { CredentialsStoreAction action = s.getStoreAction(); if (action != null) { result.add(action); } } } return result; }
/** * Exposes the {@link #getLocalStores()} {@link CredentialsStore#getStoreAction()}. * * @return the {@link #getLocalStores()} {@link CredentialsStore#getStoreAction()}. */ @NonNull @SuppressWarnings("unused") // Jelly EL public List<CredentialsStoreAction> getStoreActions() { List<CredentialsStoreAction> result = new ArrayList<CredentialsStoreAction>(); for (final CredentialsStore s : CredentialsProvider.lookupStores(getContext())) { if (context == s.getContext() && s.hasPermission(CredentialsProvider.VIEW)) { CredentialsStoreAction action = s.getStoreAction(); if (action != null) { result.add(action); } } } return result; }
/** * Checks if this action should be visible. * * @return {@code true} if the action should be visible. */ public boolean isVisible() { CredentialsStore store = getStore(); if (!store.getProvider().isEnabled()) { return false; } CredentialsStoreAction storeAction = store.getStoreAction(); if (storeAction != null && this != storeAction) { // 2.0+ implementations of CredentialsStore should be returning their action via getStoreAction() // and we want to display that action from ViewCredentialsAction // Old implementations will be returning null from getStoreAction() so we let them display as before // Forward looking implementations written against the old API will want to "hide" their old // action and display the new one returned from getStoreAction() which is what this hook enables. return false; } return store.hasPermission(CredentialsProvider.VIEW) && !store.getCredentialsDescriptors().isEmpty(); }
/** * Checks if this action should be visible. * * @return {@code true} if the action should be visible. */ public boolean isVisible() { CredentialsStore store = getStore(); if (!store.getProvider().isEnabled()) { return false; } CredentialsStoreAction storeAction = store.getStoreAction(); if (storeAction != null && this != storeAction) { // 2.0+ implementations of CredentialsStore should be returning their action via getStoreAction() // and we want to display that action from ViewCredentialsAction // Old implementations will be returning null from getStoreAction() so we let them display as before // Forward looking implementations written against the old API will want to "hide" their old // action and display the new one returned from getStoreAction() which is what this hook enables. return false; } return store.hasPermission(CredentialsProvider.VIEW) && !store.getCredentialsDescriptors().isEmpty(); }
/** * Exposes the {@link #getStoreActions()} by {@link CredentialsStoreAction#getUrlName()} for Stapler. * * @param name the {@link CredentialsStoreAction#getUrlName()} to match. * @return the {@link CredentialsStoreAction} or {@code null} */ @CheckForNull @SuppressWarnings("unused") // Stapler binding public CredentialsStoreAction getStore(String name) { for (final CredentialsStore s : CredentialsProvider.lookupStores(getContext())) { if (context == s.getContext()) { // local stores only CredentialsStoreAction action = s.getStoreAction(); if (action != null && name.equals(action.getUrlName())) { return s.hasPermission(CredentialsProvider.VIEW) ? action : null; } } } return null; }
/** * Creates the context menu with the supplied prefix to all URLs. * * @param prefix the prefix to prepend to relative urls. * @return the {@link ContextMenu} or {@code null} * @since 2.0 */ @CheckForNull public ContextMenu getContextMenu(String prefix) { ContextMenu menu = new ContextMenu(); if (getStore().isDomainsModifiable() && getStore().hasPermission(MANAGE_DOMAINS)) { menu.add(ContextMenuIconUtils.buildUrl(prefix, "newDomain"), getMenuItemIconUrlByClassSpec("icon-credentials-new-domain icon-md"), Messages.CredentialsStoreAction_AddDomainAction() ); } for (Action action : getActions()) { ContextMenuIconUtils.addMenuItem(menu, prefix, action); } return menu.items.isEmpty() ? null : menu; }