Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2007 The JA-SIG Collaborative. All rights reserved. See license
   * distributed with this file and available online at
   * http://www.ja-sig.org/products/cas/overview/license/
   */
  package org.jasig.cas.adaptors.ldap;
  
 import  org.springframework.ldap.core.LdapTemplate;
 import  org.springframework.ldap.core.ContextSource;
 
Abstract class to handle common LDAP functionality.

Author(s):
Scott Battaglia
Version:
$Revision$ $Date$
Since:
3.0.3
 
 public abstract class AbstractLdapUsernamePasswordAuthenticationHandler extends
LdapTemplate to execute ldap queries.
 
     @NotNull
     private LdapTemplate ldapTemplate;
    
    
Instance of ContextSource
 
     @NotNull
     private ContextSource contextSource;

    
The filter path to the uid of the user.
 
     @NotNull
     private String filter;
    
    
Whether the LdapTemplate should ignore partial results.
 
     private boolean ignorePartialResultException = false;

    
Method to set the datasource and generate a JdbcTemplate.

Parameters:
contextSource the datasource to use.
 
     public final void setContextSource(final ContextSource contextSource) {
         this. = contextSource;
     }
     
     public final void setIgnorePartialResultException(final boolean ignorePartialResultException) {
         this. = ignorePartialResultException;
     }

    
Method to return the LdapTemplate

Returns:
a fully created LdapTemplate.
 
     protected final LdapTemplate getLdapTemplate() {
         return this.;
     }
 
     protected final ContextSource getContextSource() {
         return this.;
     }
 
     protected final String getFilter() {
         return this.;
     }
 
     public final void afterPropertiesSet() throws Exception {
         Assert.isTrue(this..contains("%u") || this..contains("%U"), "filter must contain %u or %U");
 
         if (this. == null) {
             this. = new LdapTemplate(this.);
         }
 
         this..setIgnorePartialResultException(this.);
         afterPropertiesSetInternal();
     }

    
Available ONLY for subclasses that are doing special things with the ContextSource.

Parameters:
ldapTemplate the LDAPTemplate to use.
 
     protected final void setLdapTemplate(final LdapTemplate ldapTemplate) {
         this. = ldapTemplate;
     }
 
     protected void afterPropertiesSetInternal() throws Exception {
         // template method with nothing to do for sub classes.
     }

    

Parameters:
filter The filter to set.
 
     public final void setFilter(final String filter) {
         this. = filter;
    }
New to GrepCode? Check out our FAQ X