Class DuoSupport


  • public final class DuoSupport
    extends Object
    Helpers for DuoWeb and Duo AuthAPI operations.
    Since:
    3.3.0
    • Field Detail

      • RFC_2822_DATE_FORMAT

        public static final DateTimeFormatter RFC_2822_DATE_FORMAT
        RFC 2822 formatter for date/time.
    • Constructor Detail

      • DuoSupport

        private DuoSupport()
        Constructor.
    • Method Detail

      • generateSignedRequestToken

        @Nonnull
        @NotEmpty
        public static String generateSignedRequestToken​(@Nonnull
                                                        DuoIntegration duo,
                                                        @Nonnull @NotEmpty
                                                        String username)
                                                 throws com.duosecurity.duoweb.DuoWebException
        Created a signed request to Duo for a user.
        Parameters:
        duo - integration parameters to use
        username - user to authenticate
        Returns:
        the signed request string
        Throws:
        com.duosecurity.duoweb.DuoWebException - if an error occurs
      • canonRequest

        private static String canonRequest​(@Nonnull
                                           org.apache.http.client.methods.RequestBuilder request,
                                           @Nonnull
                                           String date,
                                           int sigVersion)
                                    throws UnsupportedEncodingException
        The signature requires that the request parameters being in a particular order as specified in the API.
        Parameters:
        request - the request
        date - the date
        sigVersion - the signature version
        Returns:
        the parameters to be signed in their canonical order
        Throws:
        UnsupportedEncodingException - failure from URLEncoder
      • createQueryString

        private static String createQueryString​(@Nonnull
                                                List<org.apache.http.NameValuePair> params)
                                         throws UnsupportedEncodingException
        Builds a string representation of the query string with the parameter names is alphabetical order. The names and values are URL encoded and then they are concatenated with '&' in between.
        Parameters:
        params - the name/value pairs to be joined
        Returns:
        the canonical query string
        Throws:
        UnsupportedEncodingException - failure from URLEncoder