Class RefreshTokenHandler

  • All Implemented Interfaces:
    io.vertx.core.Handler<io.vertx.ext.web.RoutingContext>, io.vertx.ext.web.handler.BodyHandler
    Direct Known Subclasses:
    RevokeTokenHandler

    public class RefreshTokenHandler
    extends io.vertx.ext.web.handler.impl.BodyHandlerImpl
    Author:
    Paul Withers Handlers for refreshing OAuth tokens. Bearer token expected on incoming. If included, the token is refreshed with the relevant provider
    • Field Summary

      • Fields inherited from interface io.vertx.ext.web.handler.BodyHandler

        DEFAULT_BODY_LIMIT, DEFAULT_DELETE_UPLOADED_FILES_ON_END, DEFAULT_MERGE_FORM_ATTRIBUTES, DEFAULT_PREALLOCATE_BODY_BUFFER, DEFAULT_UPLOADS_DIRECTORY
    • Constructor Summary

      Constructors 
      Constructor Description
      RefreshTokenHandler​(io.vertx.ext.auth.oauth2.OAuth2Auth oAuthProvider, String providerName)
      Constructor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected io.vertx.core.http.HttpServerResponse createJsonResponse​(io.vertx.ext.web.RoutingContext ctx)
      Creates a JSON Response with basic headers
      protected void endWithError​(io.vertx.ext.web.RoutingContext ctx, int status, String errMsg)
      Ends a request by sending an error code
      protected io.vertx.core.Future<Void> extractToken​(io.vertx.ext.web.RoutingContext ctx, String storeKey)
      Future to verify a bearer token was passed and seed it into the User object
      protected io.vertx.ext.auth.oauth2.OAuth2Auth getOAuthProvider()  
      protected String getProviderName()  
      void handle​(io.vertx.ext.web.RoutingContext ctx)  
      • Methods inherited from class io.vertx.ext.web.handler.impl.BodyHandlerImpl

        setBodyLimit, setDeleteUploadedFilesOnEnd, setHandleFileUploads, setMergeFormAttributes, setPreallocateBodyBuffer, setUploadsDirectory
    • Constructor Detail

      • RefreshTokenHandler

        public RefreshTokenHandler​(io.vertx.ext.auth.oauth2.OAuth2Auth oAuthProvider,
                                   String providerName)
        Constructor
        Parameters:
        oAuthProvider - OAuth2Auth provider seeded client ID and secret
        providerName - OAuth provider's name
    • Method Detail

      • getOAuthProvider

        protected io.vertx.ext.auth.oauth2.OAuth2Auth getOAuthProvider()
        Returns:
        the OAuth2Auth provider for this endpoint
      • getProviderName

        protected String getProviderName()
        Returns:
        the OAuth provider name for this endpoint
      • createJsonResponse

        protected io.vertx.core.http.HttpServerResponse createJsonResponse​(io.vertx.ext.web.RoutingContext ctx)
        Creates a JSON Response with basic headers
        Parameters:
        ctx - RoutingContext for the request
        Returns:
        HttpServerResponse to send back to the user
      • endWithError

        protected void endWithError​(io.vertx.ext.web.RoutingContext ctx,
                                    int status,
                                    String errMsg)
        Ends a request by sending an error code
        Parameters:
        ctx - Context
        status - HTTP error code to return
        errMsg - to be returned to the user
      • extractToken

        protected io.vertx.core.Future<Void> extractToken​(io.vertx.ext.web.RoutingContext ctx,
                                                          String storeKey)
        Future to verify a bearer token was passed and seed it into the User object
        Parameters:
        ctx - RoutingContext for the request
        storeKey - the property within the User object in which to store the token
        Returns:
        succeeded or failed future
      • handle

        public void handle​(io.vertx.ext.web.RoutingContext ctx)
        Specified by:
        handle in interface io.vertx.core.Handler<io.vertx.ext.web.RoutingContext>
        Overrides:
        handle in class io.vertx.ext.web.handler.impl.BodyHandlerImpl