// 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/commands/FilteredCommand.java
// public class FilteredCommand {
// 	
// 	private String command;
// 	private String argument;
// 
// 	public FilteredCommand() {
// 	}
// 	
// 	public FilteredCommand(String command, String argument) {
// 		this.command = command;
// 		this.argument = argument;
// 	}
// 
// 	public void setArgument(String argument) {
// 		this.argument = argument;
// 	}
// 	
// 	public void setCommand(String command) {
// 		this.command = command;
// 	}
// 
// 	public String getCommand() {
// 		return this.command;
// 	}
// 
// 	public String getArgument() {
// 		return this.argument;
// 	}
// 	
// 	@Override
// 	public String toString()
// 	{
// 		return "Filtered Command: " + getCommand() + ", " + getArgument();
// 	}
// 
// }
// 
// Path: src/main/java/com/asolutions/scmsshd/commands/factories/GitSCMCommandFactory.java
// public class GitSCMCommandFactory implements ISCMCommandFactory {
// 
// 	public static final String REPOSITORY_BASE = "repositoryBase";
// 
// 	public Command create(FilteredCommand filteredCommand,
// 			IProjectAuthorizer projectAuthorizer,
// 			IPathToProjectNameConverter pathToProjectNameConverter,
// 			Properties configuration) {
// 		SCMCommand retVal = new SCMCommand(filteredCommand, projectAuthorizer, new GitSCMCommandHandler(), pathToProjectNameConverter, configuration);
// 		return retVal;
// 	}
// 
// }
// 
// Path: src/main/java/com/asolutions/scmsshd/exceptions/MustHaveWritePrivilagesToPushFailure.java
// public class MustHaveWritePrivilagesToPushFailure extends Failure{
// 
// 	private static final long serialVersionUID = 7650486977318806435L;
// 
// 	public MustHaveWritePrivilagesToPushFailure(String specifics) {
// 		super(0, "You must have write privilages to be able to push", specifics);
// 	}
// 	
// }


import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Properties;
import org.apache.sshd.server.CommandFactory.ExitCallback;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.spearce.jgit.lib.Repository;
import org.spearce.jgit.transport.ReceivePack;
import com.asolutions.scmsshd.authorizors.AuthorizationLevel;
import com.asolutions.scmsshd.commands.FilteredCommand;
import com.asolutions.scmsshd.commands.factories.GitSCMCommandFactory;
import com.asolutions.scmsshd.exceptions.MustHaveWritePrivilagesToPushFailure;
package com.asolutions.scmsshd.commands.git;




public class GitReceivePackSCMCommandHandler extends GitSCMCommandImpl {
	protected final Logger log = LoggerFactory.getLogger(getClass());

	private GitSCMRepositoryProvider repositoryProvider;
	private GitReceivePackProvider receivePackProvider;

	public GitReceivePackSCMCommandHandler() {
		this(new GitSCMRepositoryProvider(), new GitReceivePackProvider());
	}

	public GitReceivePackSCMCommandHandler(
			GitSCMRepositoryProvider repoProvider,
			GitReceivePackProvider uploadPackProvider) {
		this.repositoryProvider = repoProvider;
		this.receivePackProvider = uploadPackProvider;
	}

	protected void runCommand(FilteredCommand filteredCommand,
			InputStream inputStream, OutputStream outputStream,
			OutputStream errorStream, ExitCallback exitCallback,
			Properties config, AuthorizationLevel authorizationLevel) throws IOException {
// 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/commands/FilteredCommand.java
// public class FilteredCommand {
// 	
// 	private String command;
// 	private String argument;
// 
// 	public FilteredCommand() {
// 	}
// 	
// 	public FilteredCommand(String command, String argument) {
// 		this.command = command;
// 		this.argument = argument;
// 	}
// 
// 	public void setArgument(String argument) {
// 		this.argument = argument;
// 	}
// 	
// 	public void setCommand(String command) {
// 		this.command = command;
// 	}
// 
// 	public String getCommand() {
// 		return this.command;
// 	}
// 
// 	public String getArgument() {
// 		return this.argument;
// 	}
// 	
// 	@Override
// 	public String toString()
// 	{
// 		return "Filtered Command: " + getCommand() + ", " + getArgument();
// 	}
// 
// }
// 
// Path: src/main/java/com/asolutions/scmsshd/commands/factories/GitSCMCommandFactory.java
// public class GitSCMCommandFactory implements ISCMCommandFactory {
// 
// 	public static final String REPOSITORY_BASE = "repositoryBase";
// 
// 	public Command create(FilteredCommand filteredCommand,
// 			IProjectAuthorizer projectAuthorizer,
// 			IPathToProjectNameConverter pathToProjectNameConverter,
// 			Properties configuration) {
// 		SCMCommand retVal = new SCMCommand(filteredCommand, projectAuthorizer, new GitSCMCommandHandler(), pathToProjectNameConverter, configuration);
// 		return retVal;
// 	}
// 
// }
// 
// Path: src/main/java/com/asolutions/scmsshd/exceptions/MustHaveWritePrivilagesToPushFailure.java
// public class MustHaveWritePrivilagesToPushFailure extends Failure{
// 
// 	private static final long serialVersionUID = 7650486977318806435L;
// 
// 	public MustHaveWritePrivilagesToPushFailure(String specifics) {
// 		super(0, "You must have write privilages to be able to push", specifics);
// 	}
// 	
// }


// Path: src/main/java/com/asolutions/scmsshd/commands/git/GitReceivePackSCMCommandHandler.java
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Properties;
import org.apache.sshd.server.CommandFactory.ExitCallback;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.spearce.jgit.lib.Repository;
import org.spearce.jgit.transport.ReceivePack;
import com.asolutions.scmsshd.authorizors.AuthorizationLevel;
import com.asolutions.scmsshd.commands.FilteredCommand;
import com.asolutions.scmsshd.commands.factories.GitSCMCommandFactory;
import com.asolutions.scmsshd.exceptions.MustHaveWritePrivilagesToPushFailure;

package com.asolutions.scmsshd.commands.git;




public class GitReceivePackSCMCommandHandler extends GitSCMCommandImpl {
	protected final Logger log = LoggerFactory.getLogger(getClass());

	private GitSCMRepositoryProvider repositoryProvider;
	private GitReceivePackProvider receivePackProvider;

	public GitReceivePackSCMCommandHandler() {
		this(new GitSCMRepositoryProvider(), new GitReceivePackProvider());
	}

	public GitReceivePackSCMCommandHandler(
			GitSCMRepositoryProvider repoProvider,
			GitReceivePackProvider uploadPackProvider) {
		this.repositoryProvider = repoProvider;
		this.receivePackProvider = uploadPackProvider;
	}

	protected void runCommand(FilteredCommand filteredCommand,
			InputStream inputStream, OutputStream outputStream,
			OutputStream errorStream, ExitCallback exitCallback,
			Properties config, AuthorizationLevel authorizationLevel) throws IOException {
		if (authorizationLevel == AuthorizationLevel.AUTH_LEVEL_READ_ONLY){