Class ClientCredentialsAccessTokenProvider

    • Field Detail

      • CONF_REQUEST_TIMEOUT

        public static final String CONF_REQUEST_TIMEOUT
        Configuration key for the HttpRequest timeout.
        See Also:
        Constant Field Values
      • CONF_TOKEN_ENDPOINT

        public static final String CONF_TOKEN_ENDPOINT
        Configuration key for the token endpoint.
        See Also:
        Constant Field Values
      • CONF_CLIENT_SECRET

        public static final String CONF_CLIENT_SECRET
        Configuration key for the client secret.
        See Also:
        Constant Field Values
      • tokenEndpoint

        protected final URI tokenEndpoint
        The token endpoint.
      • postRequestData

        protected final HttpRequest.BodyPublisher postRequestData
        The data to send as post request to get an OAuth 2.0 access token.
      • clientTimeout

        protected final long clientTimeout
        The HttpClient timeout.
      • requestTimeout

        protected final long requestTimeout
        The HttpRequest timeout.
    • Constructor Detail

      • ClientCredentialsAccessTokenProvider

        public ClientCredentialsAccessTokenProvider​(org.apache.commons.configuration2.Configuration conf,
                                                    EventManager em,
                                                    Registry registry)
                                             throws AbortServiceException
        Creates a new provider for an OAuth 2.0 token from a specific endpoint.
        Parameters:
        conf - The configuration of this OAuth 2.0 token provider.
        em - The event manager this provider is a plugin of.
        registry - The registry starting this plugin.
        Throws:
        AbortServiceException - If there are problems creating a URI for the configured endpoint, an AbortServiceException wrapping the corresponding URISyntaxException will be thrown.
    • Method Detail

      • createRequestData

        protected HttpRequest.BodyPublisher createRequestData​(org.apache.commons.configuration2.Configuration conf)
        Creates a HttpRequest.BodyPublisher that turns the values from the designated configuration into appropriate URL-encoded form data.
        Parameters:
        conf - The configuration to get the request data from.
        Returns:
        The designated data as URL-encoded form data.
      • getAccessToken

        public String getAccessToken()
                              throws javax.mail.MessagingException
        Description copied from interface: OAuth2AccessTokenProvider
        Gets an OAuth2 access token for accessing the mailbox.
        Specified by:
        getAccessToken in interface OAuth2AccessTokenProvider
        Returns:
        An OAuth2 access token for accessing the mailbox
        Throws:
        javax.mail.MessagingException - If there are problems retrieving the access token, a MessagingException will be thrown.