var AtomProxyPost = {
	wsse_generator : function (user, pass, wsse_func){
		return function (endpoint){
			//WSSE認証パラメタを作る。
			// nonce : リピート攻撃を避けるためのワンタイムなランダム文字列
			// now : リピート攻撃を避けるためのタイムスタンプ
			// digest : base64(sha1( nonce . now . password ))
			// クライアントサイドでsha1ハッシュを作るので、
			// 中継者(Buzzurlのサーバを含む)にパスワードを知られることなく認証可能
			// タイムスタンプとnonceにより、リピート攻撃も回避可能
			// 実装は http://www.sixapart.com/pronet/docs/typepad_atom_api より。
			var cred = wsse_func(pass);
			return {
				"endpoint"	: endpoint,
				"username"	: user,
				"nonce"		: cred[0],
				"now"		: cred[1],
				"digest"	: cred[2]
			};
		};
	}

	,list : function(generator, endpoint, callback) {
		var data = generator(endpoint);
		var api = new API("/atom/proxy/post/list");
		api.post(data, callback);
	}

	, post : function(generator, endpoint, title, content, callback) {
		var data = generator(endpoint);
		data.title = title;
		data.content = content;
		var api = new API("/atom/proxy/post/post");
		api.post(data, callback);
	}

	, endpoint : function(type){
		var endpoint = {
			typepad	: "http://www.typepad.jp/t/atom/weblog",
			livedoor: "http://cms.blog.livedoor.com/atom/",
			ameblo	: "http://atomblog.ameba.jp/servlet/_atom/blog",
			sonet	: "http://blog.so-net.ne.jp/_atom/blog"
		};
		return endpoint[type];
	}

	, wsse_func : function(type){
		return (type == "ameblo") ? AtomProxyPost.wsse_ameba : wsse;
	}

	, wsse_ameba : function(Password) {
		var PasswordDigest, Nonce, Created;
		var r = new Array;
		
		Nonce = b64_sha1(isodatetime() + 'There is more than words');
		nonceEncoded = encode64(Nonce);
		Created = isodatetime();
		PasswordDigest = b64_sha1(Nonce + Created + MD5_hexhash(Password));

		r[0] = nonceEncoded;
		r[1] = Created;
		r[2] = PasswordDigest;
		return r;
	}
};
