Class CredentialsStore

    • Method Detail

      • getScopes

        @Nullable
        public final Set<CredentialsScope> getScopes()
        Returns the CredentialsScope instances that are applicable to this store.
        Returns:
        the CredentialsScope instances that are applicable to this store or null if the store instance is no longer enabled.
        Since:
        2.1.5
      • getContext

        @NonNull
        public abstract ModelObject getContext()
        Returns the context within which this store operates. Credentials in this store will be available to child contexts (unless CredentialsScope.SYSTEM is valid for the store) but will not be available to parent contexts.
        Returns:
        the context within which this store operates.
      • hasPermission2

        public boolean hasPermission2​(@NonNull
                                      org.springframework.security.core.Authentication a,
                                      @NonNull
                                      Permission permission)
        Checks if the given principle has the given permission.
        Specified by:
        hasPermission2 in interface AccessControlled
        Parameters:
        a - the principle.
        permission - the permission.
        Returns:
        false if the user doesn't have the permission.
        Since:
        TODO
      • checkPermission

        public final void checkPermission​(@NonNull
                                          Permission p)
        Checks if the current security principal has this permission.

        Note: This is just a convenience function.

        Specified by:
        checkPermission in interface AccessControlled
        Throws:
        AccessDeniedException3 - if the user doesn't have the permission.
      • hasPermission

        public final boolean hasPermission​(@NonNull
                                           Permission p)
        Checks if the current security principal has this permission.
        Specified by:
        hasPermission in interface AccessControlled
        Returns:
        false if the user doesn't have the permission.
      • getDomains

        @NonNull
        public List<Domain> getDomains()
        Returns all the Domains that this credential provider has. Most implementers of CredentialsStore will probably want to override this method.
        Returns:
        the list of domains.
      • getDomainByName

        @CheckForNull
        public Domain getDomainByName​(@CheckForNull
                                      String name)
        Retrieves the domain with the matching name.
        Parameters:
        name - the name (or null to match Domain.global() as that is the domain with a null name)
        Returns:
        the domain or null if there is no domain with the supplied name.
        Since:
        2.1.1
      • getCredentials

        @NonNull
        public abstract List<Credentials> getCredentials​(@NonNull
                                                         Domain domain)
        Returns an unmodifiable list of credentials for the specified domain.
        Parameters:
        domain - the domain.
        Returns:
        the possibly empty (e.g. for an unknown Domain) unmodifiable list of credentials for the specified domain.
      • addDomain

        public final boolean addDomain​(@NonNull
                                       Domain domain,
                                       Credentials... credentials)
                                throws IOException
        Adds a new Domain with seed credentials.
        Parameters:
        domain - the domain.
        credentials - the initial credentials with which to populate the domain.
        Returns:
        true if the CredentialsStore was modified.
        Throws:
        IOException - if the change could not be persisted.
      • addDomain

        public boolean addDomain​(@NonNull
                                 Domain domain,
                                 List<Credentials> credentials)
                          throws IOException
        Adds a new Domain with seed credentials.
        Parameters:
        domain - the domain.
        credentials - the initial credentials with which to populate the domain.
        Returns:
        true if the CredentialsStore was modified.
        Throws:
        IOException - if the change could not be persisted.
      • updateDomain

        public boolean updateDomain​(@NonNull
                                    Domain current,
                                    @NonNull
                                    Domain replacement)
                             throws IOException
        Updates an existing Domain keeping the existing associated Credentials.
        Parameters:
        current - the domain to update.
        replacement - the new replacement domain.
        Returns:
        true if the CredentialsStore was modified.
        Throws:
        IOException - if the change could not be persisted.
      • updateCredentials

        public abstract boolean updateCredentials​(@NonNull
                                                  Domain domain,
                                                  @NonNull
                                                  Credentials current,
                                                  @NonNull
                                                  Credentials replacement)
                                           throws IOException
        Updates the specified Credentials from the specified Domain for this CredentialsStore with the supplied replacement.
        Parameters:
        domain - the domain.
        current - the credentials to update.
        replacement - the new replacement credentials.
        Returns:
        true if the CredentialsStore was modified.
        Throws:
        IOException - if the change could not be persisted.
      • _isApplicable

        protected boolean _isApplicable​(Descriptor<?> descriptor)
        CredentialsStore subtypes can override this method to veto some Descriptors from being available from their store. This is often useful when you are building a custom store that holds a specific type of credentials or where you want to limit the number of choices given to the users.
        Parameters:
        descriptor - the Descriptor to check.
        Returns:
        true if the supplied Descriptor is applicable in this CredentialsStore
        Since:
        2.0
      • getRelativeLinkToContext

        @CheckForNull
        public String getRelativeLinkToContext()
        Computes the relative path from the current page to this store.
        Returns:
        the relative path from the current page or null
        Since:
        2.0
      • getRelativeLinkToAction

        @CheckForNull
        public String getRelativeLinkToAction()
        Computes the relative path from the current page to this store.
        Returns:
        the relative path from the current page or null
        Since:
        2.0
      • getRelativeLinkTo

        @CheckForNull
        public String getRelativeLinkTo​(Domain domain)
        Computes the relative path from the current page to the specified domain.
        Parameters:
        domain - the domain
        Returns:
        the relative path from the current page or null
        Since:
        2.0
      • getContextDisplayName

        public final String getContextDisplayName()
        Returns the display name of the getContext() of this CredentialsStore. The default implementation can handle both Item and ItemGroup as long as these are accessible from Jenkins, and User. If the CredentialsStore provides an alternative getContext() that is outside of the normal tree then that implementation is responsible for overriding this method to produce the correct display name.
        Returns:
        the display name.
        Since:
        2.0
      • getDisplayName

        public String getDisplayName()
        Resolves a display name from the Store
        Returns:
        the display name