Class BaseAccessTokenController
- java.lang.Object
-
- org.springframework.context.support.ApplicationObjectSupport
-
- org.springframework.web.context.support.WebApplicationObjectSupport
-
- org.springframework.web.servlet.support.WebContentGenerator
-
- org.springframework.web.servlet.mvc.AbstractController
-
- jetbrains.buildServer.controllers.BaseController
-
- jetbrains.buildServer.serverSide.oauth.BaseAccessTokenController
-
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,org.springframework.context.ApplicationContextAware
,org.springframework.web.context.ServletContextAware
,org.springframework.web.servlet.mvc.Controller
- Direct Known Subclasses:
AzureDevOpsAccessTokenController
,BitBucketAccessTokenController
,GitHubAccessTokenController
,GitLabAccessTokenController
,GoogleAccessTokenController
,SpaceAccessTokenController
public abstract class BaseAccessTokenController extends BaseController
-
-
Field Summary
Fields Modifier and Type Field Description protected IssueTokenService
myIssueTokenService
protected OAuthFlow
myOAuthFlow
protected UniqueRedirectService
myUniqueRedirectService
protected WebLinks
myWebLinks
-
Fields inherited from class jetbrains.buildServer.controllers.BaseController
myServer
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
BaseAccessTokenController(OAuthConnectionsManager oauthConnectionsManager, String path, WebLinks webLinks, OAuthFlow oAuthFlow)
protected
BaseAccessTokenController(OAuthConnectionsManager oauthConnectionsManager, String path, WebLinks webLinks, OAuthFlow oAuthFlow, IssueTokenService issueTokenService)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected org.springframework.web.servlet.ModelAndView
beforeCompleteAuthorization(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Map<String,String> stateContainer)
protected UniqueRedirectService.RedirectIdCheckResult
checkRedirectId(javax.servlet.http.HttpServletRequest request, String projectId, String connectionId)
protected abstract org.springframework.web.servlet.ModelAndView
completeAuthorization(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Map<String,String> stateContainer)
protected OAuthFlow.OAuthResult
completeOAuth(OAuthConnectionDescriptor descriptor, javax.servlet.http.HttpServletRequest request)
protected Map<String,String>
createStateContainer(javax.servlet.http.HttpServletRequest request, String projectId, String connectionId)
Creates a state container with common values.protected org.springframework.web.servlet.ModelAndView
doHandle(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
Performs actual request processingprotected String
getRedirectToOAuthProvider(OAuthConnectionDescriptor descriptor, Map<String,String> stateParameters, String scope)
protected org.springframework.web.servlet.ModelAndView
handleMissingAction(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
void
init()
protected org.springframework.web.servlet.ModelAndView
internalRedirect(javax.servlet.http.HttpServletRequest request, String callbackUrl)
protected abstract org.springframework.web.servlet.ModelAndView
obtainToken(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
Redirect the user to the oauth providerprotected OAuthToken
postProcessTokenAfterIssuing(javax.servlet.http.HttpServletRequest request, Map<String,String> stateContainer, OAuthConnectionDescriptor connection, OAuthToken token)
protected String
redirectUri(OAuthConnectionDescriptor connectionDescriptor)
protected void
registerController(WebControllerManager webControllerManager)
Register this controller under the pathmyPath
.protected void
registerController(WebControllerManager webControllerManager, String typeForUniqueRedirect)
Register this controller under the pathmyPath
.protected org.springframework.web.servlet.ModelAndView
reportError(String message)
protected org.springframework.web.servlet.ModelAndView
reportError(String message, javax.servlet.http.HttpServletRequest request, Throwable cause)
void
setProjectManager(ProjectManager projectManager)
void
setUniqueRedirectService(UniqueRedirectService uniqueRedirectService)
-
Methods inherited from class jetbrains.buildServer.controllers.BaseController
getOrCreateMessages, handleRequest, handleRequestInternal, isGet, isPost, redirectTo, setExceptionResolvers, simpleView
-
Methods inherited from class org.springframework.web.servlet.mvc.AbstractController
isSynchronizeOnSession, setSynchronizeOnSession
-
Methods inherited from class org.springframework.web.servlet.support.WebContentGenerator
applyCacheControl, applyCacheSeconds, applyCacheSeconds, cacheForSeconds, cacheForSeconds, checkAndPrepare, checkAndPrepare, checkRequest, getAllowHeader, getCacheControl, getCacheSeconds, getSupportedMethods, getVaryByRequestHeaders, isAlwaysMustRevalidate, isRequireSession, isUseCacheControlHeader, isUseCacheControlNoStore, isUseExpiresHeader, prepareResponse, preventCaching, setAlwaysMustRevalidate, setCacheControl, setCacheSeconds, setRequireSession, setSupportedMethods, setUseCacheControlHeader, setUseCacheControlNoStore, setUseExpiresHeader, setVaryByRequestHeaders
-
Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext
-
-
-
-
Field Detail
-
myWebLinks
@NotNull protected final WebLinks myWebLinks
-
myOAuthFlow
@NotNull protected final OAuthFlow myOAuthFlow
-
myIssueTokenService
@Nullable protected final IssueTokenService myIssueTokenService
-
myUniqueRedirectService
@Nullable protected UniqueRedirectService myUniqueRedirectService
-
-
Constructor Detail
-
BaseAccessTokenController
@Deprecated protected BaseAccessTokenController(@NotNull OAuthConnectionsManager oauthConnectionsManager, @NotNull String path, @NotNull WebLinks webLinks, @NotNull OAuthFlow oAuthFlow)
Deprecated.This constructor only exists for backwards compatibility. A controller using this constructor will not be able to be used with enhanced token issuing functionality, like user-specified project scopes.
-
BaseAccessTokenController
protected BaseAccessTokenController(@NotNull OAuthConnectionsManager oauthConnectionsManager, @NotNull String path, @NotNull WebLinks webLinks, @NotNull OAuthFlow oAuthFlow, @Nullable IssueTokenService issueTokenService)
-
-
Method Detail
-
init
@PostConstruct public void init()
-
registerController
protected void registerController(@NotNull WebControllerManager webControllerManager)
Register this controller under the pathmyPath
. Unique redirect URLs will not be supported for this controller.- Parameters:
webControllerManager
- web controller manager to use
-
registerController
protected void registerController(@NotNull WebControllerManager webControllerManager, @Nullable String typeForUniqueRedirect)
Register this controller under the pathmyPath
. If unique redirect URLs should be supported, the type parameter must be specified too. This will register this controller also under a path structured like this:/oauth/{typeForUniqueRedirect}/rid:{redirectId}/accessToken.html
Example with type = bitbucket:/oauth/bitbucket/rid:wi82wkwerif234f/accessToken.html
- Parameters:
webControllerManager
- web controller manager to usetypeForUniqueRedirect
- controller / provider type; needs to be specified if unique redirects should be supported- Since:
- 2024.03
- See Also:
UniqueRedirectUtil#buildControllerPath(String)
-
doHandle
@Nullable protected org.springframework.web.servlet.ModelAndView doHandle(@NotNull javax.servlet.http.HttpServletRequest request, @NotNull javax.servlet.http.HttpServletResponse response) throws Exception
Description copied from class:BaseController
Performs actual request processing- Specified by:
doHandle
in classBaseController
- Parameters:
request
- HTTP requestresponse
- HTTP response- Returns:
- model and view components
- Throws:
Exception
- exception
-
obtainToken
@Nullable protected abstract org.springframework.web.servlet.ModelAndView obtainToken(@NotNull javax.servlet.http.HttpServletRequest request, @NotNull javax.servlet.http.HttpServletResponse response) throws Exception
Redirect the user to the oauth provider- Throws:
Exception
-
completeAuthorization
@NotNull protected abstract org.springframework.web.servlet.ModelAndView completeAuthorization(@NotNull javax.servlet.http.HttpServletRequest request, @NotNull javax.servlet.http.HttpServletResponse response, @NotNull Map<String,String> stateContainer) throws Exception
- Throws:
Exception
-
beforeCompleteAuthorization
@Nullable protected org.springframework.web.servlet.ModelAndView beforeCompleteAuthorization(@NotNull javax.servlet.http.HttpServletRequest request, @NotNull javax.servlet.http.HttpServletResponse response, @NotNull Map<String,String> stateContainer) throws Exception
- Throws:
Exception
-
handleMissingAction
@Nullable protected org.springframework.web.servlet.ModelAndView handleMissingAction(@NotNull javax.servlet.http.HttpServletRequest request, @NotNull javax.servlet.http.HttpServletResponse response) throws Exception
- Throws:
Exception
-
redirectUri
@NotNull protected String redirectUri(@NotNull OAuthConnectionDescriptor connectionDescriptor)
-
completeOAuth
@NotNull protected OAuthFlow.OAuthResult completeOAuth(@NotNull OAuthConnectionDescriptor descriptor, @NotNull javax.servlet.http.HttpServletRequest request)
-
getRedirectToOAuthProvider
@NotNull protected String getRedirectToOAuthProvider(@NotNull OAuthConnectionDescriptor descriptor, @NotNull Map<String,String> stateParameters, @Nullable String scope)
-
internalRedirect
@NotNull protected org.springframework.web.servlet.ModelAndView internalRedirect(@NotNull javax.servlet.http.HttpServletRequest request, @NotNull String callbackUrl)
-
createStateContainer
@NotNull protected Map<String,String> createStateContainer(@NotNull javax.servlet.http.HttpServletRequest request, @NotNull String projectId, @NotNull String connectionId)
Creates a state container with common values. The returned Map is mutable, to allow for the addition of further state variables.- Parameters:
request
- HTTP servlet requestprojectId
- project IDconnectionId
- connection ID- Returns:
- mutable Map of state variable to state value
-
postProcessTokenAfterIssuing
@NotNull protected OAuthToken postProcessTokenAfterIssuing(@NotNull javax.servlet.http.HttpServletRequest request, @Nullable Map<String,String> stateContainer, @NotNull OAuthConnectionDescriptor connection, @NotNull OAuthToken token)
-
reportError
protected org.springframework.web.servlet.ModelAndView reportError(@NotNull String message)
-
reportError
protected org.springframework.web.servlet.ModelAndView reportError(@NotNull String message, @Nullable javax.servlet.http.HttpServletRequest request, @Nullable Throwable cause)
-
checkRedirectId
@NotNull protected UniqueRedirectService.RedirectIdCheckResult checkRedirectId(@NotNull javax.servlet.http.HttpServletRequest request, @NotNull String projectId, @NotNull String connectionId)
-
setUniqueRedirectService
@Autowired(required=false) public void setUniqueRedirectService(@NotNull UniqueRedirectService uniqueRedirectService)
-
setProjectManager
@Autowired(required=false) public void setProjectManager(@NotNull ProjectManager projectManager)
-
-