Interface ImpersonationService

  • All Known Implementing Classes:
    ImpersonationServiceImpl

    public interface ImpersonationService
    Allows you to run something in the context of a user A replica of this exists in the Jira Bamboo Plugin.
    • Method Detail

      • runAsUser

        @NotNull
        <V> @NotNull Callable<V> runAsUser​(@NotNull
                                           @NotNull String username,
                                           @NotNull
                                           @NotNull Callable<V> delegate)
        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.
        Parameters:
        username - username to set the authentication context to.
        delegate - callable to execute in the new context
        Returns:
        callable
        Throws:
        IllegalArgumentException - if username is invalid
        IllegalStateException - if it fails to set up the authentication correctly.
      • runWithOptionalUserImpersonation

        @NotNull
        <V> @NotNull Callable<V> runWithOptionalUserImpersonation​(@Nullable
                                                                  @Nullable String username,
                                                                  @NotNull
                                                                  @NotNull Callable<V> delegate)
        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.
        Parameters:
        username - (optional) to set the authentication context to
        delegate - callable to execute in the new context
        Returns:
        callable
      • runWithAuthenticationImpersonation

        @NotNull
        @Deprecated
        <V> @NotNull Callable<V> runWithAuthenticationImpersonation​(@NotNull
                                                                    @NotNull org.acegisecurity.Authentication authentication,
                                                                    @NotNull
                                                                    @NotNull Callable<V> delegate)
        Deprecated.
        since 5.4 use @{link ImpersonationHelper} instead
        Delegates the given runnable so that it can run in the context of a given authentication.
        Parameters:
        authentication - to set the authentication context to
        delegate - callable to execute in the new context
        Returns:
        callable
      • runWith

        void runWith​(@NotNull
                     @NotNull org.acegisecurity.Authentication authentication,
                     @NotNull
                     BambooRunnables.NotThrowing notThrowing)
        Runs a given Bamboo runnable with supplied Authentication.