/** * Expose the backing {@link CredentialsStore}. * * @return the backing {@link CredentialsStore}. */ public CredentialsStore getStore() { return getParent().getStore(); }
/** * {@inheritDoc} */ @Nonnull @Override public ACL getACL() { return getStore().getACL(); }
/** * Expose the backing {@link CredentialsStore}. * * @return the backing {@link CredentialsStore}. */ public CredentialsStore getStore() { return getParent().getStore(); }
/** * Exposes {@link CredentialsStore#isDomainsModifiable()} for Jelly. * * @return {@link CredentialsStore#isDomainsModifiable()}. */ public boolean isDomainsModifiable() { return getStore().isDomainsModifiable(); }
/** * Exposes {@link CredentialsStore#isDomainsModifiable()} for Jelly. * * @return {@link CredentialsStore#isDomainsModifiable()}. */ public boolean isDomainsModifiable() { return getStore().isDomainsModifiable(); }
/** * {@inheritDoc} */ @Nonnull @Override public ACL getACL() { return getStore().getACL(); }
/** * {@inheritDoc} */ @Override public String getUrlName() { CredentialsStore store = getStore(); if (this == store.getStoreAction()) { Class<?> c = store.getClass(); while (c.getEnclosingClass() != null) { c = c.getEnclosingClass(); } String name = c.getSimpleName().replaceAll("(?i)(Impl|Credentials|Provider|Store)+", ""); if (StringUtils.isBlank(name)) { name = c.getSimpleName(); } return StringUtils.join(StringUtils.splitByCharacterTypeCamelCase(name), '-').toLowerCase(Locale.ENGLISH); } else { return "credential-store"; } }
/** * {@inheritDoc} */ @Override public String getDisplayName() { CredentialsStore store = getStore(); if (this == store.getStoreAction()) { Class<?> c = store.getClass(); while (c.getEnclosingClass() != null) { c = c.getEnclosingClass(); } String name = c.getSimpleName().replaceAll("(?i)(Impl|Credentials|Provider|Store)+", ""); if (StringUtils.isBlank(name)) { name = c.getSimpleName(); } return StringUtils.join(StringUtils.splitByCharacterTypeCamelCase(name), ' '); } else { return Messages.CredentialsStoreAction_DisplayName(); } }
/** * {@inheritDoc} */ @Override public String getUrlName() { CredentialsStore store = getStore(); if (this == store.getStoreAction()) { Class<?> c = store.getClass(); while (c.getEnclosingClass() != null) { c = c.getEnclosingClass(); } String name = c.getSimpleName().replaceAll("(?i)(Impl|Credentials|Provider|Store)+", ""); if (StringUtils.isBlank(name)) { name = c.getSimpleName(); } return StringUtils.join(StringUtils.splitByCharacterTypeCamelCase(name), '-').toLowerCase(Locale.ENGLISH); } else { return "credential-store"; } }
/** * {@inheritDoc} */ @Override public String getDisplayName() { CredentialsStore store = getStore(); if (this == store.getStoreAction()) { Class<?> c = store.getClass(); while (c.getEnclosingClass() != null) { c = c.getEnclosingClass(); } String name = c.getSimpleName().replaceAll("(?i)(Impl|Credentials|Provider|Store)+", ""); if (StringUtils.isBlank(name)) { name = c.getSimpleName(); } return StringUtils.join(StringUtils.splitByCharacterTypeCamelCase(name), ' '); } else { return Messages.CredentialsStoreAction_DisplayName(); } }
/** * Returns the map of {@link DomainWrapper} instances. * * @return the map of {@link DomainWrapper} instances. */ @Exported @NonNull public Map<String, DomainWrapper> getDomains() { Map<String, DomainWrapper> result = new TreeMap<String, DomainWrapper>(); for (Domain d : getStore().getDomains()) { String name; if (d.isGlobal()) { name = "_"; } else { name = d.getName(); } result.put(name, new DomainWrapper(this, d)); } 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(); }
/** * Returns the map of {@link DomainWrapper} instances. * * @return the map of {@link DomainWrapper} instances. */ @Exported @NonNull public Map<String, DomainWrapper> getDomains() { Map<String, DomainWrapper> result = new TreeMap<String, DomainWrapper>(); for (Domain d : getStore().getDomains()) { String name; if (d.isGlobal()) { name = "_"; } else { name = d.getName(); } result.put(name, new DomainWrapper(this, d)); } return result; }
/** * 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; }
/** * 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; }
/** * Returns the {@link Item#getFullName()} or nearest approximation. * * @return the {@link Item#getFullName()} or nearest approximation. */ public final String getFullName() { String n; ModelObject context = getStore().getContext(); if (context instanceof Item) { n = ((Item) context).getFullName(); } else if (context instanceof ItemGroup) { n = ((ItemGroup) context).getFullName(); } else if (context instanceof User) { n = "user:" + ((User) context).getId(); } else { n = ""; } if (n.length() == 0) { return getUrlName(); } else { return n + '/' + getUrlName(); } }
/** * Similar to {@link #isScopeRelevant()} but used by {@link CredentialsSelectHelper}. * * @param wrapper the wrapper for the domain that is going to contain the credential. * @return {@code true} if there is more than one {@link CredentialsScope} that can be used for the specified * object. * @since 2.1.5 */ @SuppressWarnings("unused") // used by stapler @Restricted(NoExternalUse.class) public boolean isScopeRelevant(CredentialsSelectHelper.WrappedCredentialsStore wrapper) { if (wrapper != null) { return isScopeRelevant(wrapper.getStore().getContext()); } CredentialsStoreAction action = Stapler.getCurrentRequest().findAncestorObject(CredentialsStoreAction.class); if (action != null) { return isScopeRelevant(action.getStore().getContext()); } return isScopeRelevant(); }
/** * Creates the children 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 getChildrenContextMenu(String prefix) { ContextMenu menu = new ContextMenu(); for (Domain d : getStore().getDomains()) { MenuItem item = new MenuItem(d.getUrl(), getMenuItemIconUrlByClassSpec("icon-credentials-domain icon-md"), d.isGlobal() ? Messages.CredentialsStoreAction_GlobalDomainDisplayName() : d.getName() ); item.subMenu = new DomainWrapper(this, d).getContextMenu(ContextMenuIconUtils.buildUrl(prefix, d.getUrl())); menu.add(item); } return menu.items.isEmpty() ? null : menu; }
/** * Similar to {@link #isScopeRelevant()} but used by {@link CredentialsStoreAction}. * * @param wrapper the wrapper for the domain that is going to contain the credential. * @return {@code true} if there is more than one {@link CredentialsScope} that can be used for the specified * object. */ @SuppressWarnings("unused") // used by stapler @Restricted(NoExternalUse.class) @RestrictedSince("2.1.5") public boolean isScopeRelevant(CredentialsStoreAction.DomainWrapper wrapper) { if (wrapper != null) { return isScopeRelevant(wrapper.getStore().getContext()); } CredentialsStoreAction action = Stapler.getCurrentRequest().findAncestorObject(CredentialsStoreAction.class); if (action != null) { return isScopeRelevant(action.getStore().getContext()); } return isScopeRelevant(); }
/** * Similar to {@link #isScopeRelevant()} but used by {@link CredentialsStoreAction}. * * @param wrapper the wrapper for the domain that is going to contain the credential. * @return {@code true} if there is more than one {@link CredentialsScope} that can be used for the specified * object. */ @SuppressWarnings("unused") // used by stapler @Restricted(NoExternalUse.class) @RestrictedSince("2.1.5") public boolean isScopeRelevant(CredentialsStoreAction.CredentialsWrapper wrapper) { if (wrapper != null) { return isScopeRelevant(wrapper.getStore().getContext()); } CredentialsStoreAction action = Stapler.getCurrentRequest().findAncestorObject(CredentialsStoreAction.class); if (action != null) { return isScopeRelevant(action.getStore().getContext()); } return isScopeRelevant(); }