You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Kevin Sonney <ke...@webslingerz.com> on 2000/07/28 16:38:46 UTC
LDAP Diff
Gang -
Here's my diff agains the LDAP Processor. I'd really like to see this in
version 1.8 (as I posted it back in 1.7.3 or so, and it *STILL* hasn't
made it in).
This exposes the request header vars, and some other tidbits.
Enjoy!
Index: LdapQueryCreator.java
===================================================================
RCS file: /home/cvspublic/xml-cocoon/src/org/apache/cocoon/processor/ldap/LdapQueryCreator.java,v
retrieving revision 1.2
diff -u -r1.2 LdapQueryCreator.java
--- LdapQueryCreator.java 2000/02/13 18:29:31 1.2
+++ LdapQueryCreator.java 2000/07/28 14:39:46
@@ -63,8 +63,9 @@
* parameters table from cocoon that notably may contain a HttpServletRequest
* object keyed from "request".<br>
* adapted from Donald Ball's SQLProcessor code.
+ * Modified by <a href="mailto:kevin@webslignerz.com">Kevin Sonney</a> to support header and some CGI variables
* @author <a href="mailto:jmbirchfield@proteus-technologies.com">James Birchfield</a>
- * @version 1.0
+ * @version 1.0a
*/
public class LdapQueryCreator {
@@ -82,7 +83,55 @@
int rindex = query.indexOf(rdelim,offset+llength);
if (rindex < 0 || rindex < lindex) break;
String name = query.substring(lindex+llength,rindex);
- String value = req.getParameter(name);
+ String value = null;
+ // Kevin Sonney's Modifications to get more than just
+ // passed variables.
+ //attempt to identify if the is a "named" variable request
+ if (name.indexOf(":") > 0) {
+ // Yes, it is. split the varaible name from the request space it's
+ // supposed to be in
+ String getValueFrom = name.substring(0,name.indexOf(":"));
+ name = name.substring(name.indexOf(":")+1,name.length());
+ // sanity check for debugging
+ // System.err.println("LDAP DEBUG -- name is '"+name+"' and from is '"+getValueFrom+"'");
+ if (getValueFrom.equalsIgnoreCase("header")) {
+ // This is a value in the Request header.
+ // The servlet 2.0 API doesn't always allow direct acces to all variables
+ // we'll hard-code in some special cases.
+ // The first of these is the REMOTE_USER
+ if (name.equalsIgnoreCase("remote_user")) {
+ value = req.getRemoteUser();
+ } else
+ // next up, AUTH_TYPE
+ if (name.equalsIgnoreCase("auth_type")) {
+ value = req.getAuthType();
+ } else
+ // The Method
+ if (name.equalsIgnoreCase("method")) {
+ value = req.getMethod();
+ // we can add more cases as needed, or we can
+ // just hope that they get picked up *grin*
+ } else {
+ // no special handler for the requested information
+ // so we'll just ask for it here.
+ value = req.getHeader(name);
+ }
+
+ } else
+ // OK, it's not a header, so we chack to see if it's a parameter request.
+ if (getValueFrom.equalsIgnoreCase("parameter")) {
+ value = req.getParameter(name);
+ } else {
+ // the failsafe is to assume it's a parameter request if not explicitly
+ // specified as such.
+ value = req.getParameter(name);
+ }
+ } else {
+ // No specific request area to review, therefor it must be a parameter
+ // request.
+ value = req.getParameter(name);
+ }
+ // End Kevin's Modifications
if (value == null) break;
query = query.substring(0,lindex)+value+query.substring(rindex+rlength);
offset = lindex+value.length();
--
+-------------------------------------------+
| Kevin Sonney kevin@webslingerZ.com |
| Systems Programmer www.webslingerZ.com |
+-------------------------------------------+