Class UserCredentialsProvider.StoreImpl
- java.lang.Object
-
- com.cloudbees.plugins.credentials.CredentialsStore
-
- com.cloudbees.plugins.credentials.UserCredentialsProvider.StoreImpl
-
- All Implemented Interfaces:
Saveable
,AccessControlled
- Enclosing class:
- UserCredentialsProvider
public static class UserCredentialsProvider.StoreImpl extends CredentialsStore
Our implementation
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addCredentials(Domain domain, Credentials credentials)
boolean
addDomain(Domain domain, List<Credentials> credentials)
Adds a newDomain
with seed credentials.ACL
getACL()
ModelObject
getContext()
Returns the context within which this store operates.List<Credentials>
getCredentials(Domain domain)
Returns an unmodifiable list of credentials for the specified domain.List<Domain>
getDomains()
Returns all theDomain
s that this credential provider has.String
getRelativeLinkToContext()
Computes the relative path from the current page to this store.CredentialsStoreAction
getStoreAction()
Return theCredentialsStoreAction
for this store.boolean
hasPermission(Authentication a, Permission permission)
Checks if the given principle has the given permission.boolean
removeCredentials(Domain domain, Credentials credentials)
boolean
removeDomain(Domain domain)
Removes an existingDomain
and all associatedCredentials
.void
save()
Persists the state of this object into XML.boolean
updateCredentials(Domain domain, Credentials current, Credentials replacement)
Updates the specifiedCredentials
from the specifiedDomain
for thisCredentialsStore
with the supplied replacement.boolean
updateDomain(Domain current, Domain replacement)
Updates an existingDomain
keeping the existing associatedCredentials
.-
Methods inherited from class com.cloudbees.plugins.credentials.CredentialsStore
_isApplicable, addDomain, checkPermission, getContextDisplayName, getCredentialsDescriptors, getDisplayName, getDomainByName, getProvider, getProviderOrDie, getRelativeLinkTo, getRelativeLinkToAction, getScopes, hasPermission, isApplicable, isDomainsModifiable
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface hudson.security.AccessControlled
checkAnyPermission, hasAnyPermission, hasPermission2
-
-
-
-
Method Detail
-
getStoreAction
@Nullable public CredentialsStoreAction getStoreAction()
Return theCredentialsStoreAction
for this store. The action will be displayed as a sub-item of theViewCredentialsAction
. Returnnull
if this store will take control of displaying its action (which will be the case for legacy implementations)- Overrides:
getStoreAction
in classCredentialsStore
- Returns:
- the
CredentialsStoreAction
for this store to be rendered inViewCredentialsAction
ornull
for old implementations compiled against pre 2.0 versions of credentials plugin.
-
getContext
@NonNull public ModelObject getContext()
Returns the context within which this store operates. Credentials in this store will be available to child contexts (unlessCredentialsScope.SYSTEM
is valid for the store) but will not be available to parent contexts.- Specified by:
getContext
in classCredentialsStore
- Returns:
- the context within which this store operates.
-
hasPermission
public boolean hasPermission(@NonNull Authentication a, @NonNull Permission permission)
Checks if the given principle has the given permission.- Specified by:
hasPermission
in interfaceAccessControlled
- Specified by:
hasPermission
in classCredentialsStore
- Parameters:
a
- the principle.permission
- the permission.- Returns:
false
if the user doesn't have the permission.
-
getACL
@NonNull public ACL getACL()
- Specified by:
getACL
in interfaceAccessControlled
- Overrides:
getACL
in classCredentialsStore
-
getDomains
@NonNull @Exported public List<Domain> getDomains()
Returns all theDomain
s that this credential provider has. Most implementers ofCredentialsStore
will probably want to override this method.- Overrides:
getDomains
in classCredentialsStore
- Returns:
- the list of domains.
-
getCredentials
@NonNull @Exported public List<Credentials> getCredentials(@NonNull Domain domain)
Returns an unmodifiable list of credentials for the specified domain.- Specified by:
getCredentials
in classCredentialsStore
- Parameters:
domain
- the domain.- Returns:
- the possibly empty (e.g. for an unknown
Domain
) unmodifiable list of credentials for the specified domain.
-
addDomain
public boolean addDomain(@NonNull Domain domain, List<Credentials> credentials) throws IOException
Adds a newDomain
with seed credentials.- Overrides:
addDomain
in classCredentialsStore
- Parameters:
domain
- the domain.credentials
- the initial credentials with which to populate the domain.- Returns:
true
if theCredentialsStore
was modified.- Throws:
IOException
- if the change could not be persisted.
-
removeDomain
public boolean removeDomain(@NonNull Domain domain) throws IOException
Removes an existingDomain
and all associatedCredentials
.- Overrides:
removeDomain
in classCredentialsStore
- Parameters:
domain
- the domain.- Returns:
true
if theCredentialsStore
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 existingDomain
keeping the existing associatedCredentials
.- Overrides:
updateDomain
in classCredentialsStore
- Parameters:
current
- the domain to update.replacement
- the new replacement domain.- Returns:
true
if theCredentialsStore
was modified.- Throws:
IOException
- if the change could not be persisted.
-
addCredentials
public boolean addCredentials(@NonNull Domain domain, @NonNull Credentials credentials) throws IOException
- Specified by:
addCredentials
in classCredentialsStore
- Parameters:
domain
- the domain.credentials
- the credentials- Returns:
true
if theCredentialsStore
was modified.- Throws:
IOException
- if the change could not be persisted.
-
removeCredentials
public boolean removeCredentials(@NonNull Domain domain, @NonNull Credentials credentials) throws IOException
- Specified by:
removeCredentials
in classCredentialsStore
- Parameters:
domain
- the domain.credentials
- the credentials- Returns:
true
if theCredentialsStore
was modified.- Throws:
IOException
- if the change could not be persisted.
-
updateCredentials
public boolean updateCredentials(@NonNull Domain domain, @NonNull Credentials current, @NonNull Credentials replacement) throws IOException
Updates the specifiedCredentials
from the specifiedDomain
for thisCredentialsStore
with the supplied replacement.- Specified by:
updateCredentials
in classCredentialsStore
- Parameters:
domain
- the domain.current
- the credentials to update.replacement
- the new replacement credentials.- Returns:
true
if theCredentialsStore
was modified.- Throws:
IOException
- if the change could not be persisted.
-
getRelativeLinkToContext
public String getRelativeLinkToContext()
Computes the relative path from the current page to this store.- Overrides:
getRelativeLinkToContext
in classCredentialsStore
- Returns:
- the relative path from the current page or
null
-
save
public void save() throws IOException
Persists the state of this object into XML. Default implementation delegates toCredentialsStore.getContext()
if it implementsSaveable
otherwise dropping back to a no-op.- Specified by:
save
in interfaceSaveable
- Overrides:
save
in classCredentialsStore
- Throws:
IOException
- See Also:
Saveable.save()
-
-