Package com.atlassian.bamboo.applinks
Class ImpersonationServiceImpl
- java.lang.Object
-
- com.atlassian.bamboo.applinks.ImpersonationServiceImpl
-
- All Implemented Interfaces:
ImpersonationService
public class ImpersonationServiceImpl extends Object implements ImpersonationService
-
-
Field Summary
Fields Modifier and Type Field Description static String
USER_TOKEN_KEY
-
Constructor Summary
Constructors Constructor Description ImpersonationServiceImpl(BambooUserManager bambooUserManager)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <V> @NotNull Callable<V>
runAsUser(@NotNull String username, @NotNull Callable<V> callable)
Delegates the given callable so that it can run in the context of the given user.void
runWith(@NotNull org.acegisecurity.Authentication authentication, BambooRunnables.NotThrowing notThrowing)
Runs a given Bamboo runnable with supplied Authentication.<V> @NotNull Callable<V>
runWithAuthenticationImpersonation(@NotNull org.acegisecurity.Authentication authentication, @NotNull Callable<V> delegate)
Delegates the given runnable so that it can run in the context of a given authentication.<V> @NotNull Callable<V>
runWithOptionalUserImpersonation(@Nullable String username, @NotNull Callable<V> callable)
Delegates the given runnable so that it can run in the context of the given user.
-
-
-
Field Detail
-
USER_TOKEN_KEY
public static final String USER_TOKEN_KEY
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ImpersonationServiceImpl
public ImpersonationServiceImpl(BambooUserManager bambooUserManager)
-
-
Method Detail
-
runAsUser
@NotNull public <V> @NotNull Callable<V> runAsUser(@NotNull @NotNull String username, @NotNull @NotNull Callable<V> callable)
Description copied from interface:ImpersonationService
Delegates the given callable so that it can run in the context of the given user. If the context can not be set to the given user it will fail.- Specified by:
runAsUser
in interfaceImpersonationService
- Parameters:
username
- username to set the authentication context to.callable
- callable to execute in the new context- Returns:
- callable
-
runWithOptionalUserImpersonation
@NotNull public <V> @NotNull Callable<V> runWithOptionalUserImpersonation(@Nullable @Nullable String username, @NotNull @NotNull Callable<V> callable)
Description copied from interface:ImpersonationService
Delegates the given runnable so that it can run in the context of the given user. If use context can not be set it will execute the callable regardless.- Specified by:
runWithOptionalUserImpersonation
in interfaceImpersonationService
- Parameters:
username
- (optional) to set the authentication context tocallable
- callable to execute in the new context- Returns:
- callable
-
runWithAuthenticationImpersonation
@NotNull public <V> @NotNull Callable<V> runWithAuthenticationImpersonation(@NotNull @NotNull org.acegisecurity.Authentication authentication, @NotNull @NotNull Callable<V> delegate)
Description copied from interface:ImpersonationService
Delegates the given runnable so that it can run in the context of a given authentication.- Specified by:
runWithAuthenticationImpersonation
in interfaceImpersonationService
- Parameters:
authentication
- to set the authentication context todelegate
- callable to execute in the new context- Returns:
- callable
-
runWith
public void runWith(@NotNull @NotNull org.acegisecurity.Authentication authentication, @NotNull BambooRunnables.NotThrowing notThrowing)
Description copied from interface:ImpersonationService
Runs a given Bamboo runnable with supplied Authentication.- Specified by:
runWith
in interfaceImpersonationService
-
-