You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2003/11/24 15:06:49 UTC

cvs commit: cocoon-lenya/src/java/org/apache/lenya/ac/ldap LDAPUser.java

andreas     2003/11/24 06:06:49

  Modified:    src/java/org/apache/lenya/ac/ldap LDAPUser.java
  Log:
  authorization can fail now
  
  Revision  Changes    Path
  1.2       +19 -8     cocoon-lenya/src/java/org/apache/lenya/ac/ldap/LDAPUser.java
  
  Index: LDAPUser.java
  ===================================================================
  RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/ac/ldap/LDAPUser.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LDAPUser.java	13 Nov 2003 16:07:12 -0000	1.1
  +++ LDAPUser.java	24 Nov 2003 14:06:49 -0000	1.2
  @@ -50,6 +50,8 @@
   import org.apache.lenya.ac.file.*;
   import org.apache.log4j.Category;
   
  +import com.sun.jndi.ldap.LdapCtxFactory;
  +
   import java.io.File;
   import java.io.FileInputStream;
   import java.io.IOException;
  @@ -267,22 +269,31 @@
   
   		String principal =
   			"uid=" + getLdapId() + "," + defaultProperties.getProperty(PARTIAL_USER_DN);
  -		Context ctx;
  +		Context ctx = null;
   
  -		log.debug("Authenticating with principal [" + principal + "]");
  +        if (log.isDebugEnabled()) {
  +            log.debug("Authenticating with principal [" + principal + "]");
  +        }
  +        
  +        boolean authenticated = false;
   
   		try {
   			ctx = bind(principal, password);
  -			close(ctx);
  -			log.debug("Context closed.");
  +            authenticated = true;
  +            close(ctx);
  +            if (log.isDebugEnabled()) {
  +                log.debug("Context closed.");
  +            }
   		} catch (NamingException e) {
   			// log this failure
   			// StringWriter writer = new StringWriter();
   			// e.printStackTrace(new PrintWriter(writer));
  -			log.info("Bind for user " + principal + " to Ldap server failed: ", e);
  +            if (log.isInfoEnabled()) {
  +                log.info("Bind for user " + principal + " to Ldap server failed: ", e);
  +            }
   		}
   
  -		return true;
  +		return authenticated;
   	}
   
   	/**
  @@ -348,7 +359,7 @@
   				+ File.separator
   				+ defaultProperties.getProperty(KEY_STORE));
   
  -		env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
  +		env.put(Context.INITIAL_CONTEXT_FACTORY, LdapCtxFactory.class.getName());
   		env.put(Context.PROVIDER_URL, defaultProperties.getProperty(PROVIDER_URL));
   		env.put(Context.SECURITY_PROTOCOL, defaultProperties.getProperty(SECURITY_PROTOCOL));
   		env.put(
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: lenya-cvs-unsubscribe@cocoon.apache.org
For additional commands, e-mail: lenya-cvs-help@cocoon.apache.org