[jcifs] Custom HttpServletRequest [patch]
Marcin Cieslak
saper at sgh.waw.pl
Fri Feb 25 22:46:03 GMT 2005
After playing a bit with JCIFS for NTLM authentication I missed the
possibility to add custom servlet request overriding some methods (for
example custom isUserInRole(String role) method).
My proposal is to add additional factory method to NtlmHttpFilter that
decouples the NtlmHttpServletRequest from the filter code.
With this patch it is easy to provide your own filter using all the
power of the JCIFS's filter. See example custom filter:
import javax.servlet.http.HttpServletRequest;
import jcifs.smb.NtlmPasswordAuthentication;
public class MyOwnNtlmHttpFilter extends jcifs.http.NtlmHttpFilter {
protected HttpServletRequest ServletRequestFactory(
HttpServletRequest request, NtlmPasswordAuthentication ntlm) {
return new MyOwnHttpServletRequest(request, ntlm);
}
}
I think that this approach is much simpler and powerful than what
jfs-ext folks did:
http://42.pl/url/b1k
Thanks for providing nice piece of code!
--Marcin
-------------- next part --------------
diff -ruN jcifs_1.1.8.orig/src/jcifs/http/NtlmHttpFilter.java jcifs_1.1.8/src/jcifs/http/NtlmHttpFilter.java
--- jcifs_1.1.8.orig/src/jcifs/http/NtlmHttpFilter.java Thu Feb 10 22:30:18 2005
+++ jcifs_1.1.8/src/jcifs/http/NtlmHttpFilter.java Fri Feb 25 21:15:10 2005
@@ -198,7 +198,7 @@
}
}
- chain.doFilter( new NtlmHttpServletRequest( req, ntlm ), response );
+ chain.doFilter( ServletRequestFactory(req, ntlm), response );
}
// Added by cgross to work with weblogic 6.1.
@@ -209,6 +209,13 @@
e.printStackTrace();
}
}
+ /*
+ * Factory method to provide custom user prinicipals.
+ */
+ protected HttpServletRequest ServletRequestFactory(HttpServletRequest request, NtlmPasswordAuthentication ntlm) {
+ return new NtlmHttpServletRequest(request, ntlm);
+ }
+
public FilterConfig getFilterConfig() {
return null;
}
More information about the jcifs
mailing list