首页>代码>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;
	}
}


最近下载更多
微信网友_6790966844739584  LV5 2024年6月12日
ewan007  LV30 2024年2月24日
是夜在熬我.  LV6 2024年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日
最近浏览更多
周粥粥 4月11日
暂无贡献等级
zhangkk  LV7 2月8日
微信网友_6955249237250048  LV5 2024年12月28日
txf123  LV6 2024年12月10日
sjwc88  LV3 2024年12月4日
pangzhihui  LV14 2024年11月12日
火心人  LV2 2024年11月1日
颜菜菜  LV2 2024年9月13日
曾显示  LV6 2024年7月7日
binzhuyou  LV2 2024年7月4日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友