// Path: src/main/java/com/asolutions/scmsshd/authenticators/LDAPUsernameResolver.java
// public class LDAPUsernameResolver {
// 	LDAPBindingProvider provider;
// 	private String userBase;
// 	private String matchingElement;
// 	public LDAPUsernameResolver(LDAPBindingProvider provider, String userBase) {
// 		this(provider, userBase, "cn=");
// 	}
// 	public LDAPUsernameResolver(LDAPBindingProvider provider, String userBase, String matchingElement) {
// 		this.provider = provider;
// 		this.userBase = userBase;
// 		this.matchingElement = matchingElement;
// 	}
// 	
// 	public String resolveUserName(String username) throws NamingException{
// 		InitialDirContext InitialDirectoryContext = provider.getBinding();
// 		SearchControls searchCtls = new SearchControls();
// 		//Specify the search scope
// 		searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE);
// 
// 		//specify the LDAP search filter
// 		String searchFilter = "("+matchingElement+username+")";
// 
// 		//initialize counter to total the results
// 
// 		// Search for objects using the filter
// 		NamingEnumeration<SearchResult> answer = InitialDirectoryContext.search(userBase, searchFilter, searchCtls);
// 		SearchResult next = answer.next();
// 		return next.getNameInNamespace();
// 	}
// }
// 
// Path: src/main/java/com/asolutions/scmsshd/authorizors/AuthorizationLevel.java
// public enum AuthorizationLevel {
// 	AUTH_LEVEL_READ_ONLY, 
// 	AUTH_LEVEL_READ_WRITE;
// }
// 
// Path: src/main/java/com/asolutions/scmsshd/sshd/IProjectAuthorizer.java
// public interface IProjectAuthorizer {
// 
// 	AuthorizationLevel userIsAuthorizedForProject(String username, String project) throws UnparsableProjectException;
// 
// }
// 
// Path: src/main/java/com/asolutions/scmsshd/sshd/UnparsableProjectException.java
// public class UnparsableProjectException extends Exception {
// 
// 	private static final long serialVersionUID = 643951700141491862L;
// 
// 	public UnparsableProjectException(String reason) {
// 		super(reason);
// 	}
// 
// }


import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.naming.directory.Attributes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.asolutions.scmsshd.authenticators.LDAPUsernameResolver;
import com.asolutions.scmsshd.authorizors.AuthorizationLevel;
import com.asolutions.scmsshd.sshd.IProjectAuthorizer;
import com.asolutions.scmsshd.sshd.UnparsableProjectException;
package com.asolutions.scmsshd.ldap;




public class LDAPProjectAuthorizer implements IProjectAuthorizer {
	protected final Logger log = LoggerFactory.getLogger(getClass());

	private String groupBaseDN;
	private String groupSuffix;
// Path: src/main/java/com/asolutions/scmsshd/authenticators/LDAPUsernameResolver.java
// public class LDAPUsernameResolver {
// 	LDAPBindingProvider provider;
// 	private String userBase;
// 	private String matchingElement;
// 	public LDAPUsernameResolver(LDAPBindingProvider provider, String userBase) {
// 		this(provider, userBase, "cn=");
// 	}
// 	public LDAPUsernameResolver(LDAPBindingProvider provider, String userBase, String matchingElement) {
// 		this.provider = provider;
// 		this.userBase = userBase;
// 		this.matchingElement = matchingElement;
// 	}
// 	
// 	public String resolveUserName(String username) throws NamingException{
// 		InitialDirContext InitialDirectoryContext = provider.getBinding();
// 		SearchControls searchCtls = new SearchControls();
// 		//Specify the search scope
// 		searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE);
// 
// 		//specify the LDAP search filter
// 		String searchFilter = "("+matchingElement+username+")";
// 
// 		//initialize counter to total the results
// 
// 		// Search for objects using the filter
// 		NamingEnumeration<SearchResult> answer = InitialDirectoryContext.search(userBase, searchFilter, searchCtls);
// 		SearchResult next = answer.next();
// 		return next.getNameInNamespace();
// 	}
// }
// 
// Path: src/main/java/com/asolutions/scmsshd/authorizors/AuthorizationLevel.java
// public enum AuthorizationLevel {
// 	AUTH_LEVEL_READ_ONLY, 
// 	AUTH_LEVEL_READ_WRITE;
// }
// 
// Path: src/main/java/com/asolutions/scmsshd/sshd/IProjectAuthorizer.java
// public interface IProjectAuthorizer {
// 
// 	AuthorizationLevel userIsAuthorizedForProject(String username, String project) throws UnparsableProjectException;
// 
// }
// 
// Path: src/main/java/com/asolutions/scmsshd/sshd/UnparsableProjectException.java
// public class UnparsableProjectException extends Exception {
// 
// 	private static final long serialVersionUID = 643951700141491862L;
// 
// 	public UnparsableProjectException(String reason) {
// 		super(reason);
// 	}
// 
// }


// Path: src/main/java/com/asolutions/scmsshd/ldap/LDAPProjectAuthorizer.java
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.naming.directory.Attributes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.asolutions.scmsshd.authenticators.LDAPUsernameResolver;
import com.asolutions.scmsshd.authorizors.AuthorizationLevel;
import com.asolutions.scmsshd.sshd.IProjectAuthorizer;
import com.asolutions.scmsshd.sshd.UnparsableProjectException;

package com.asolutions.scmsshd.ldap;




public class LDAPProjectAuthorizer implements IProjectAuthorizer {
	protected final Logger log = LoggerFactory.getLogger(getClass());

	private String groupBaseDN;
	private String groupSuffix;
	private AuthorizationLevel authorizationLevel;