Package org.codehaus.cargo.daemon
Class CargoDaemonAuthenticationFilter
- java.lang.Object
-
- org.codehaus.cargo.daemon.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 thePASSWORD_PROPERTIES_FILE
property (either in the filter init configuration or as a system property).
-
-
Field Summary
Fields Modifier and Type Field Description static String
PASSWORD_PROPERTIES_FILE
Property used for the password file, can be passed as a system property or a filter init param.
-
Constructor Summary
Constructors Constructor Description CargoDaemonAuthenticationFilter()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
destroy()
void
doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain)
Checks the incoming query against the known passwords.void
init(javax.servlet.FilterConfig filterConfig)
Loads the password file.static Map<String,PasswordWithHash>
parsePasswordFile(InputStream resource)
Parses a given password input stream.
-
-
-
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 byMessageDigest
.- See Also:
- Constant Field Values
-
-
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 byMessageDigest
.- 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 interfacejavax.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 interfacejavax.servlet.Filter
- Throws:
IOException
javax.servlet.ServletException
-
destroy
public void destroy()
- Specified by:
destroy
in interfacejavax.servlet.Filter
-
-