当前位置: 首页>>代码示例>>Java>>正文


Java HttpParameters.containsKey方法代码示例

本文整理汇总了Java中oauth.signpost.http.HttpParameters.containsKey方法的典型用法代码示例。如果您正苦于以下问题:Java HttpParameters.containsKey方法的具体用法?Java HttpParameters.containsKey怎么用?Java HttpParameters.containsKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在oauth.signpost.http.HttpParameters的用法示例。


在下文中一共展示了HttpParameters.containsKey方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getIpnParamsFromUrl

import oauth.signpost.http.HttpParameters; //导入方法依赖的package包/类
/**
 * 
 * @param url - The URL, no callback
 * @return - the map of the parameter, can be empty or not contain key
 * @throws IpnRequestException - if the URL is empty or not contain parameters
 */
public static Map<String,String> getIpnParamsFromUrl(String url) throws IpnRequestException{
	Map<String,String> map = new HashMap<String,String>();

	if(url==null || url.isEmpty())
		throw new IpnRequestException("Callback is Empty");
			
	int pos = url.indexOf('?');
	if(pos == -1 || pos+1>url.length())
		throw new IpnRequestException("Invalid Callback or Parameter absents");
	url = url.substring(pos+1);

	HttpParameters params = OAuth.decodeForm(url);
	if(params==null || params.isEmpty())
		throw new IpnRequestException("Invalid Callback or Parameter absents");

	if(params.containsKey(AbIpnRequest.PARAM_TARCK_ID))
		map.put(AbIpnRequest.PARAM_TARCK_ID, params.getFirst(AbIpnRequest.PARAM_TARCK_ID));
	
	if(params.containsKey(AbIpnRequest.PARAM_MERCHANT_REFERECE))
		map.put(AbIpnRequest.PARAM_MERCHANT_REFERECE, params.getFirst(AbIpnRequest.PARAM_MERCHANT_REFERECE));
	
	return map;
}
 
开发者ID:ImperiusRex,项目名称:PesapalDroid,代码行数:30,代码来源:IpnUtil.java

示例2: buildException

import oauth.signpost.http.HttpParameters; //导入方法依赖的package包/类
/**
 * Builds an exception based on the given content, assuming that it has been
 * returned as an error from the server.
 * 
 * @param code response code returned by the server
 * @param content content returned by the server
 * @param hasToken <tt>true</tt> if the request was made using a request or
 *            access token
 * @return an exception to throw for the given content
 */
private BellaDatiRuntimeException buildException(int code, byte[] content, boolean hasToken) {
	try {
		HttpParameters oauthParams = OAuth.decodeForm(new ByteArrayInputStream(content));
		if (oauthParams.containsKey("oauth_problem")) {
			String problem = oauthParams.getFirst("oauth_problem");
			if ("missing_consumer".equals(problem) || "invalid_consumer".equals(problem)) {
				return new AuthorizationException(Reason.CONSUMER_KEY_UNKNOWN);
			} else if ("invalid_signature".equals(problem) || "signature_invalid".equals(problem)) {
				return new AuthorizationException(hasToken ? Reason.TOKEN_INVALID : Reason.CONSUMER_SECRET_INVALID);
			} else if ("domain_expired".equals(problem)) {
				return new AuthorizationException(Reason.DOMAIN_EXPIRED);
			} else if ("missing_token".equals(problem) || "invalid_token".equals(problem)) {
				return new AuthorizationException(Reason.TOKEN_INVALID);
			} else if ("unauthorized_token".equals(problem)) {
				return new AuthorizationException(Reason.TOKEN_UNAUTHORIZED);
			} else if ("token_expired".equals(problem)) {
				return new AuthorizationException(Reason.TOKEN_EXPIRED);
			} else if ("x_auth_disabled".equals(problem)) {
				return new AuthorizationException(Reason.X_AUTH_DISABLED);
			} else if ("piccolo_not_enabled".equals(problem)) {
				return new AuthorizationException(Reason.BD_MOBILE_DISABLED);
			} else if ("missing_username".equals(problem) || "missing_password".equals(problem)
				|| "invalid_credentials".equals(problem) || "permission_denied".equals(problem)) {
				return new AuthorizationException(Reason.USER_CREDENTIALS_INVALID);
			} else if ("account_locked".equals(problem) || "user_not_active".equals(problem)) {
				return new AuthorizationException(Reason.USER_ACCOUNT_LOCKED);
			} else if ("domain_restricted".equals(problem)) {
				return new AuthorizationException(Reason.USER_DOMAIN_MISMATCH);
			} else if ("timestamp_refused".equals(problem)) {
				String acceptable = oauthParams.getFirst("oauth_acceptable_timestamps");
				if (acceptable != null && acceptable.contains("-")) {
					return new InvalidTimestampException(Long.parseLong(acceptable.split("-")[0]),
						Long.parseLong(acceptable.split("-")[1]));
				}
			}
			return new AuthorizationException(Reason.OTHER, problem);
		}
		return new UnexpectedResponseException(code, new String(content));
	} catch (IOException e) {
		throw new UnexpectedResponseException(code, new String(content), e);
	}

}
 
开发者ID:BellaDati,项目名称:belladati-sdk-java,代码行数:54,代码来源:BellaDatiClient.java

示例3: buildException

import oauth.signpost.http.HttpParameters; //导入方法依赖的package包/类
/**
 * Builds an exception based on the given content, assuming that it has been
 * returned as an error from the server.
 * 
 * @param code response code returned by the server
 * @param content content returned by the server
 * @param hasToken <tt>true</tt> if the request was made using a request or
 *            access token
 * @return an exception to throw for the given content
 */
private BellaDatiRuntimeException buildException(int code, byte[] content, boolean hasToken) {
	try {
		HttpParameters oauthParams = OAuth.decodeForm(new ByteArrayInputStream(content));
		if (oauthParams.containsKey("oauth_problem")) {
			String problem = oauthParams.getFirst("oauth_problem");
			if ("missing_consumer".equals(problem) || "invalid_consumer".equals(problem)) {
				return new AuthorizationException(Reason.CONSUMER_KEY_UNKNOWN);
			} else if ("invalid_signature".equals(problem) || "signature_invalid".equals(problem)) {
				return new AuthorizationException(hasToken ? Reason.TOKEN_INVALID : Reason.CONSUMER_SECRET_INVALID);
			} else if ("domain_expired".equals(problem)) {
				return new AuthorizationException(Reason.DOMAIN_EXPIRED);
			} else if ("missing_token".equals(problem) || "invalid_token".equals(problem)) {
				return new AuthorizationException(Reason.TOKEN_INVALID);
			} else if ("unauthorized_token".equals(problem)) {
				return new AuthorizationException(Reason.TOKEN_UNAUTHORIZED);
			} else if ("token_expired".equals(problem)) {
				return new AuthorizationException(Reason.TOKEN_EXPIRED);
			} else if ("x_auth_disabled".equals(problem)) {
				return new AuthorizationException(Reason.X_AUTH_DISABLED);
			} else if ("piccolo_not_enabled".equals(problem)) {
				return new AuthorizationException(Reason.BD_MOBILE_DISABLED);
			} else if ("missing_username".equals(problem) || "missing_password".equals(problem)
				|| "invalid_credentials".equals(problem) || "permission_denied".equals(problem)) {
				return new AuthorizationException(Reason.USER_CREDENTIALS_INVALID);
			} else if ("account_locked".equals(problem) || "user_not_active".equals(problem)) {
				return new AuthorizationException(Reason.USER_ACCOUNT_LOCKED);
			} else if ("domain_restricted".equals(problem)) {
				return new AuthorizationException(Reason.USER_DOMAIN_MISMATCH);
			} else if ("timestamp_refused".equals(problem)) {
				String acceptable = oauthParams.getFirst("oauth_acceptable_timestamps");
				if (acceptable != null && acceptable.contains("-")) {
					return new InvalidTimestampException(Long.parseLong(acceptable.split("-")[0]), Long.parseLong(acceptable
						.split("-")[1]));
				}
			}
			return new AuthorizationException(Reason.OTHER, problem);
		}
		return new UnexpectedResponseException(code, new String(content));
	} catch (IOException e) {
		throw new UnexpectedResponseException(code, new String(content), e);
	}

}
 
开发者ID:BellaDati,项目名称:belladati-sdk-android,代码行数:54,代码来源:BellaDatiClient.java


注:本文中的oauth.signpost.http.HttpParameters.containsKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。