首页>代码>jfinal开发java web开源微信商城源码>/jfinal-wxmall/weixin-sdk/src/main/java/com/weixin/sdk/api/ApiConfig.java
/**
 * Copyright (c) 2011-2014, James Zhan 詹波 (jfinal@126.com).
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 */

package com.weixin.sdk.api;

/**
 * 存放 Weixin 服务号需要用到的各个参数
 */
public class ApiConfig {
	
	private String token = null;
	private String appId = null;
	private String appSecret = null;
	private String encodingAesKey = null;
	private boolean messageEncrypt = false;	// 消息加密与否
	
	public ApiConfig() {
		
	}
	
	public ApiConfig(String token) {
		setToken(token);
	}
	
	public ApiConfig(String token, String appId, String appSecret) {
		setToken(token);
		setAppId(appId);
		setAppSecret(appSecret);
	}
	
	public ApiConfig(String token, String appId, String appSecret, boolean messageEncrypt, String encodingAesKey) {
		setToken(token);
		setAppId(appId);
		setAppSecret(appSecret);
		setEncryptMessage(messageEncrypt);
		setEncodingAesKey(encodingAesKey);
	}
	
	public String getToken() {
		if (token == null)
			throw new IllegalStateException("token 未被赋值");
		return token;
	}
	
	public void setToken(String token) {
		if (token == null)
			throw new IllegalArgumentException("token 值不能为 null");
		this.token = token;
	}
	
	public String getAppId() {
		if (appId == null)
			throw new IllegalStateException("appId 未被赋值");
		return appId;
	}
	
	public void setAppId(String appId) {
		if (appId == null)
			throw new IllegalArgumentException("appId 值不能为 null");
		this.appId = appId;
	}
	
	public String getAppSecret() {
		if (appSecret == null)
			throw new IllegalStateException("appSecret 未被赋值");
		return appSecret;
	}
	
	public void setAppSecret(String appSecret) {
		if (appSecret == null)
			throw new IllegalArgumentException("appSecret 值不能为 null");
		this.appSecret = appSecret;
	}
	
	public String getEncodingAesKey() {
		if (encodingAesKey == null)
			throw new IllegalStateException("encodingAesKey 未被赋值");
		return encodingAesKey;
	}
	
	public void setEncodingAesKey(String encodingAesKey) {
		if (encodingAesKey == null)
			throw new IllegalArgumentException("encodingAesKey 值不能为 null");
		this.encodingAesKey = encodingAesKey;
	}
	
	public boolean isEncryptMessage() {
		return messageEncrypt;
	}
	
	/**
	 *  是否对消息进行加密,对应于微信平台的消息加解密方式:
	 *  1:true进行加密且必须配置 encodingAesKey
	 *  2:false采用明文模式,同时也支持混合模式
	 */
	public void setEncryptMessage(boolean messageEncrypt) {
		this.messageEncrypt = messageEncrypt;
	}
}


最近下载更多
ewan007  LV29 2月24日
是夜在熬我.  LV6 2月20日
去码头整点薯条  LV3 2023年11月15日
wuying8208  LV15 2023年7月27日
gdt633  LV2 2023年6月30日
稻草人a  LV1 2023年4月6日
臧家旺  LV3 2022年12月7日
zymnba  LV2 2022年6月25日
我喜欢蔡徐坤  LV1 2022年6月20日
yiss343  LV1 2022年6月19日
最近浏览更多
李朝磊  LV18 3月6日
ewan007  LV29 2月24日
1134116035 2月24日
暂无贡献等级
是夜在熬我.  LV6 2月20日
小测子 1月20日
暂无贡献等级
sublinex 1月16日
暂无贡献等级
半夏bx  LV14 1月13日
微信网友_6786215447367680  LV4 2023年12月20日
万魔殿 2023年12月19日
暂无贡献等级
去码头整点薯条  LV3 2023年11月15日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友