Class CargoDaemonAuthenticationFilter

  • All Implemented Interfaces:
    javax.servlet.Filter

    public class CargoDaemonAuthenticationFilter
    extends Object
    implements javax.servlet.Filter
    Cargo daemon authentication filter. Supports Basic authentication only, the password file is specified using the PASSWORD_PROPERTIES_FILE property (either in the filter init configuration or as a system property).
    • Field Detail

      • PASSWORD_PROPERTIES_FILE

        public static final String PASSWORD_PROPERTIES_FILE
        Property used for the password file, can be passed as a system property or a filter init param. The password file can use hashes. Example file contents:

        cargo-daemon-user1=cargo-password
        cargo-daemon-user2={MD5}9addb63b65b01292700094b0ef056036
        cargo-daemon-user3={SHA-1}2681c738294805939045be2a4af53b687c25bf4d


        The hashing algorithms can be any algorithm supported by MessageDigest.
        See Also:
        Constant Field Values
    • Constructor Detail

      • CargoDaemonAuthenticationFilter

        public CargoDaemonAuthenticationFilter()
    • Method Detail

      • parsePasswordFile

        public static Map<String,​PasswordWithHash> parsePasswordFile​(InputStream resource)
                                                                    throws IOException,
                                                                           NoSuchAlgorithmException
        Parses a given password input stream. The contents can use hashes, some examples:

        cargo-daemon-user1=cargo-password
        cargo-daemon-user2={MD5}9addb63b65b01292700094b0ef056036
        cargo-daemon-user3={SHA-1}2681c738294805939045be2a4af53b687c25bf4d


        The hashing algorithms can be any algorithm supported by MessageDigest.
        Parameters:
        resource - Input stream for the password file.
        Returns:
        Parsed username and password pairs.
        Throws:
        IOException - If reading fails.
        NoSuchAlgorithmException - If the digest algorithm isn't known to the JVM.
      • init

        public void init​(javax.servlet.FilterConfig filterConfig)
                  throws javax.servlet.ServletException
        Loads the password file.
        Specified by:
        init in interface javax.servlet.Filter
        Throws:
        javax.servlet.ServletException
      • doFilter

        public void doFilter​(javax.servlet.ServletRequest request,
                             javax.servlet.ServletResponse response,
                             javax.servlet.FilterChain chain)
                      throws IOException,
                             javax.servlet.ServletException
        Checks the incoming query against the known passwords.
        Specified by:
        doFilter in interface javax.servlet.Filter
        Throws:
        IOException
        javax.servlet.ServletException
      • destroy

        public void destroy()
        Specified by:
        destroy in interface javax.servlet.Filter