// Path: src/main/java/com/taskadapter/redmineapi/internal/comm/Communicator.java
// public interface Communicator<K> {
// 
// 	/**
// 	 * Performs a request.
// 	 * 
// 	 * @return the response body.
// 	 */
// 	<R> R sendRequest(HttpRequest request, ContentHandler<K, R> contentHandler) throws RedmineException;
// 
// }
// 
// Path: src/main/java/com/taskadapter/redmineapi/internal/comm/ContentHandler.java
// public interface ContentHandler<K, R> {
// 	/**
// 	 * Consumes content of a specified type and returns a specified result.
// 	 * 
// 	 * @param content
// 	 *            content to process.
// 	 * @return processed content.
// 	 * @throws RedmineException
// 	 *             if something goes wrong.
// 	 */
// 	R processContent(K content) throws RedmineException;
// }
// 
// Path: src/main/java/com/taskadapter/redmineapi/RedmineException.java
// public class RedmineException extends Exception {
// 	private static final long serialVersionUID = -1592189045756043062L;
// 
// 	public RedmineException() {
//     }
// 
//     public RedmineException(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
//     public RedmineException(String message) {
//         super(message);
//     }
// 
//     public RedmineException(Throwable cause) {
//         super(cause);
//     }
// }
// 
// Path: src/main/java/com/taskadapter/redmineapi/RedmineInternalError.java
// public class RedmineInternalError extends RuntimeException {
// 
//     private static final long serialVersionUID = 1L;
// 
//     public RedmineInternalError() {
//     }
// 
//     public RedmineInternalError(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
//     public RedmineInternalError(String message) {
//         super(message);
//     }
// 
//     public RedmineInternalError(Throwable cause) {
//         super(cause);
//     }
// 
// }


import java.io.UnsupportedEncodingException;
import com.taskadapter.redmineapi.internal.comm.Communicator;
import com.taskadapter.redmineapi.internal.comm.ContentHandler;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpRequest;
import com.taskadapter.redmineapi.RedmineException;
import com.taskadapter.redmineapi.RedmineInternalError;
package com.taskadapter.redmineapi.internal.comm.redmine;



public class RedmineAuthenticator<K> implements Communicator<K> {
	/**
	 * Header value.
	 */
	private String authKey;

	/**
	 * Used charset.
	 */
	private final String charset;

	/**
	 * Peer communicator.
	 */
	private final Communicator<K> peer;

	public RedmineAuthenticator(Communicator<K> peer, String charset) {
		this.peer = peer;
		this.charset = charset;
	}

// Path: src/main/java/com/taskadapter/redmineapi/internal/comm/Communicator.java
// public interface Communicator<K> {
// 
// 	/**
// 	 * Performs a request.
// 	 * 
// 	 * @return the response body.
// 	 */
// 	<R> R sendRequest(HttpRequest request, ContentHandler<K, R> contentHandler) throws RedmineException;
// 
// }
// 
// Path: src/main/java/com/taskadapter/redmineapi/internal/comm/ContentHandler.java
// public interface ContentHandler<K, R> {
// 	/**
// 	 * Consumes content of a specified type and returns a specified result.
// 	 * 
// 	 * @param content
// 	 *            content to process.
// 	 * @return processed content.
// 	 * @throws RedmineException
// 	 *             if something goes wrong.
// 	 */
// 	R processContent(K content) throws RedmineException;
// }
// 
// Path: src/main/java/com/taskadapter/redmineapi/RedmineException.java
// public class RedmineException extends Exception {
// 	private static final long serialVersionUID = -1592189045756043062L;
// 
// 	public RedmineException() {
//     }
// 
//     public RedmineException(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
//     public RedmineException(String message) {
//         super(message);
//     }
// 
//     public RedmineException(Throwable cause) {
//         super(cause);
//     }
// }
// 
// Path: src/main/java/com/taskadapter/redmineapi/RedmineInternalError.java
// public class RedmineInternalError extends RuntimeException {
// 
//     private static final long serialVersionUID = 1L;
// 
//     public RedmineInternalError() {
//     }
// 
//     public RedmineInternalError(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
//     public RedmineInternalError(String message) {
//         super(message);
//     }
// 
//     public RedmineInternalError(Throwable cause) {
//         super(cause);
//     }
// 
// }


// Path: src/main/java/com/taskadapter/redmineapi/internal/comm/redmine/RedmineAuthenticator.java
import java.io.UnsupportedEncodingException;
import com.taskadapter.redmineapi.internal.comm.Communicator;
import com.taskadapter.redmineapi.internal.comm.ContentHandler;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpRequest;
import com.taskadapter.redmineapi.RedmineException;
import com.taskadapter.redmineapi.RedmineInternalError;

package com.taskadapter.redmineapi.internal.comm.redmine;



public class RedmineAuthenticator<K> implements Communicator<K> {
	/**
	 * Header value.
	 */
	private String authKey;

	/**
	 * Used charset.
	 */
	private final String charset;

	/**
	 * Peer communicator.
	 */
	private final Communicator<K> peer;

	public RedmineAuthenticator(Communicator<K> peer, String charset) {
		this.peer = peer;
		this.charset = charset;
	}

	public void setCredentials(String login, String password) {