diff --git a/broker/config/wildfirechat.conf b/broker/config/wildfirechat.conf index 6dc271ad..cd0e74b8 100755 --- a/broker/config/wildfirechat.conf +++ b/broker/config/wildfirechat.conf @@ -108,9 +108,6 @@ message.global_mute_exception_types 401,402,403,404,405,407,408,410,411 ## 当为true时,不转发server api发送的消息;当为false时,转发server api发送的消息。 message.no_forward_admin_message false -## 应用密钥 -application.secret_key 123456 - ##禁止搜索用户 friend.disable_search false diff --git a/broker/src/main/java/com/xiaoleilu/loServer/action/channel/VerifyApplicationUserInfoAction.java b/broker/src/main/java/com/xiaoleilu/loServer/action/channel/ApplicationGetUserInfoAction.java similarity index 72% rename from broker/src/main/java/com/xiaoleilu/loServer/action/channel/VerifyApplicationUserInfoAction.java rename to broker/src/main/java/com/xiaoleilu/loServer/action/channel/ApplicationGetUserInfoAction.java index f1e815d9..06e6cb82 100755 --- a/broker/src/main/java/com/xiaoleilu/loServer/action/channel/VerifyApplicationUserInfoAction.java +++ b/broker/src/main/java/com/xiaoleilu/loServer/action/channel/ApplicationGetUserInfoAction.java @@ -10,8 +10,9 @@ package com.xiaoleilu.loServer.action.channel; import cn.wildfirechat.common.APIPath; import cn.wildfirechat.common.ErrorCode; -import cn.wildfirechat.pojos.InputVerifyApplicationUserInfo; -import cn.wildfirechat.pojos.OutputVerifyApplicationUserInfo; +import cn.wildfirechat.pojos.InputApplicationGetUserInfo; +import cn.wildfirechat.pojos.OutputApplicationUserInfo; +import cn.wildfirechat.proto.ProtoConstants; import cn.wildfirechat.proto.WFCMessage; import com.google.gson.Gson; import com.xiaoleilu.loServer.RestResult; @@ -23,21 +24,21 @@ import io.netty.handler.codec.http.FullHttpRequest; import io.netty.handler.codec.http.HttpResponseStatus; import io.netty.util.internal.StringUtil; -@Route(APIPath.Channel_Verify_Application_UserInfo) +@Route(APIPath.Channel_Application_Get_UserInfo) @HttpMethod("POST") -public class VerifyApplicationUserInfoAction extends ChannelAction { +public class ApplicationGetUserInfoAction extends ChannelAction { @Override public boolean action(Request request, Response response) { if (request.getNettyRequest() instanceof FullHttpRequest) { - InputVerifyApplicationUserInfo inputUserToken = getRequestBody(request.getNettyRequest(), InputVerifyApplicationUserInfo.class); + InputApplicationGetUserInfo inputUserToken = getRequestBody(request.getNettyRequest(), InputApplicationGetUserInfo.class); RestResult result; - if (inputUserToken == null || StringUtil.isNullOrEmpty(inputUserToken.getToken())) { + if (inputUserToken == null || StringUtil.isNullOrEmpty(inputUserToken.getAuthCode())) { result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER); } else { - String userId = messagesStore.verifyApplicationToken(inputUserToken.getToken(), channelInfo.getTargetId()); + String userId = messagesStore.verifyApplicationAuthCode(inputUserToken.getAuthCode(), channelInfo.getTargetId(), ProtoConstants.ApplicationType.ApplicationType_Channel); if(userId != null) { - OutputVerifyApplicationUserInfo outputVerifyApplicationUser = new OutputVerifyApplicationUserInfo(); + OutputApplicationUserInfo outputVerifyApplicationUser = new OutputApplicationUserInfo(); outputVerifyApplicationUser.setUserId(userId); WFCMessage.User user = messagesStore.getUserInfo(userId); if(user != null) { diff --git a/broker/src/main/java/com/xiaoleilu/loServer/action/robot/ApplicationGetUserInfoAction.java b/broker/src/main/java/com/xiaoleilu/loServer/action/robot/ApplicationGetUserInfoAction.java new file mode 100755 index 00000000..097f992b --- /dev/null +++ b/broker/src/main/java/com/xiaoleilu/loServer/action/robot/ApplicationGetUserInfoAction.java @@ -0,0 +1,59 @@ +/* + * This file is part of the Wildfire Chat package. + * (c) Heavyrain2012 + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +package com.xiaoleilu.loServer.action.robot; + +import cn.wildfirechat.common.APIPath; +import cn.wildfirechat.common.ErrorCode; +import cn.wildfirechat.pojos.InputApplicationGetUserInfo; +import cn.wildfirechat.pojos.OutputApplicationUserInfo; +import cn.wildfirechat.proto.ProtoConstants; +import cn.wildfirechat.proto.WFCMessage; +import com.google.gson.Gson; +import com.xiaoleilu.loServer.RestResult; +import com.xiaoleilu.loServer.annotation.HttpMethod; +import com.xiaoleilu.loServer.annotation.Route; +import com.xiaoleilu.loServer.handler.Request; +import com.xiaoleilu.loServer.handler.Response; +import io.netty.handler.codec.http.FullHttpRequest; +import io.netty.handler.codec.http.HttpResponseStatus; +import io.netty.util.internal.StringUtil; + +@Route(APIPath.Robot_Application_Get_UserInfo) +@HttpMethod("POST") +public class ApplicationGetUserInfoAction extends RobotAction { + + @Override + public boolean action(Request request, Response response) { + if (request.getNettyRequest() instanceof FullHttpRequest) { + InputApplicationGetUserInfo inputUserToken = getRequestBody(request.getNettyRequest(), InputApplicationGetUserInfo.class); + RestResult result; + if (inputUserToken == null || StringUtil.isNullOrEmpty(inputUserToken.getAuthCode())) { + result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER); + } else { + String userId = messagesStore.verifyApplicationAuthCode(inputUserToken.getAuthCode(), robot.getUid(), ProtoConstants.ApplicationType.ApplicationType_Robot); + if(userId != null) { + OutputApplicationUserInfo outputVerifyApplicationUser = new OutputApplicationUserInfo(); + outputVerifyApplicationUser.setUserId(userId); + WFCMessage.User user = messagesStore.getUserInfo(userId); + if(user != null) { + outputVerifyApplicationUser.setDisplayName(user.getDisplayName()); + outputVerifyApplicationUser.setPortraitUrl(user.getPortrait()); + } + result = RestResult.ok(outputVerifyApplicationUser); + } else { + result = RestResult.resultOf(ErrorCode.ERROR_CODE_APPLICATION_TOKEN_ERROR_OR_TIMEOUT); + } + } + + response.setStatus(HttpResponseStatus.OK); + response.setContent(new Gson().toJson(result)); + } + return true; + } +} diff --git a/broker/src/main/java/io/moquette/BrokerConstants.java b/broker/src/main/java/io/moquette/BrokerConstants.java index 11d9c206..2ee3c554 100755 --- a/broker/src/main/java/io/moquette/BrokerConstants.java +++ b/broker/src/main/java/io/moquette/BrokerConstants.java @@ -176,8 +176,6 @@ public final class BrokerConstants { public static final String MESSAGES_RECALL_TIME_LIMIT = "message.recall_time_limit"; public static final String MESSAGES_DISABLE_GROUP_MANAGER_RECALL = "message.disable_group_manager_recall"; - public static final String APPLICATION_SECRET_KEY = "application.secret_key"; - public static final String HTTP_ADMIN_RATE_LIMIT = "http.admin.rate_limit"; public static final String HTTP_ROBOT_RATE_LIMIT = "http.robot.rate_limit"; public static final String HTTP_CHANNEL_RATE_LIMIT = "http.channel.rate_limit"; diff --git a/broker/src/main/java/io/moquette/imhandler/ConfigApplicationHandler.java b/broker/src/main/java/io/moquette/imhandler/ConfigApplicationHandler.java new file mode 100644 index 00000000..123a04dc --- /dev/null +++ b/broker/src/main/java/io/moquette/imhandler/ConfigApplicationHandler.java @@ -0,0 +1,28 @@ +/* + * This file is part of the Wildfire Chat package. + * (c) Heavyrain2012 + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +package io.moquette.imhandler; + +import cn.wildfirechat.common.ErrorCode; +import cn.wildfirechat.proto.ProtoConstants; +import cn.wildfirechat.proto.WFCMessage; +import io.moquette.spi.impl.Qos1PublishHandler; +import io.netty.buffer.ByteBuf; +import win.liyufan.im.IMTopic; + +import static cn.wildfirechat.common.ErrorCode.ERROR_CODE_SUCCESS; + +@Handler(IMTopic.ApplicationConfigRequestTopic) +public class ConfigApplicationHandler extends IMHandler { + @Override + public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, ProtoConstants.RequestSourceType requestSourceType, WFCMessage.ApplicationConfigRequest request, Qos1PublishHandler.IMCallback callback) { + ErrorCode errorCode = m_messagesStore.configApplication(request.getAppId(), request.getAppType(), request.getTimestamp(), request.getNonce(), request.getSignature()); + return errorCode; + } +} + diff --git a/broker/src/main/java/io/moquette/imhandler/GetApplicationTokenHandler.java b/broker/src/main/java/io/moquette/imhandler/GetApplicationTokenHandler.java index fd62d910..9cab46f6 100644 --- a/broker/src/main/java/io/moquette/imhandler/GetApplicationTokenHandler.java +++ b/broker/src/main/java/io/moquette/imhandler/GetApplicationTokenHandler.java @@ -18,12 +18,16 @@ import win.liyufan.im.IMTopic; import static cn.wildfirechat.common.ErrorCode.ERROR_CODE_SUCCESS; @Handler(IMTopic.GetApplicationTokenRequestTopic) -public class GetApplicationTokenHandler extends IMHandler { +public class GetApplicationTokenHandler extends IMHandler { @Override - public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, ProtoConstants.RequestSourceType requestSourceType, WFCMessage.IDBuf request, Qos1PublishHandler.IMCallback callback) { - String token = m_messagesStore.getApplicationToken(fromUser, request.getId()); - byte[] data = WFCMessage.IDBuf.newBuilder().setId(token).build().toByteArray(); - ackPayload.ensureWritable(data.length).writeBytes(data); - return ERROR_CODE_SUCCESS; + public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, ProtoConstants.RequestSourceType requestSourceType, WFCMessage.AuthCodeRequest request, Qos1PublishHandler.IMCallback callback) { + String authCode = m_messagesStore.getApplicationAuthCode(fromUser, request.getTargetId(), request.getType(), request.getHost()); + if(authCode != null) { + byte[] data = WFCMessage.IDBuf.newBuilder().setId(authCode).build().toByteArray(); + ackPayload.ensureWritable(data.length).writeBytes(data); + return ERROR_CODE_SUCCESS; + } + return ErrorCode.INVALID_PARAMETER; + } } diff --git a/broker/src/main/java/io/moquette/persistence/MemoryMessagesStore.java b/broker/src/main/java/io/moquette/persistence/MemoryMessagesStore.java index d10d627a..28588d91 100755 --- a/broker/src/main/java/io/moquette/persistence/MemoryMessagesStore.java +++ b/broker/src/main/java/io/moquette/persistence/MemoryMessagesStore.java @@ -35,11 +35,14 @@ import io.moquette.spi.impl.security.AES; import io.moquette.spi.security.Tokenor; import io.moquette.spi.impl.subscriptions.Topic; import io.netty.handler.codec.mqtt.MqttVersion; +import org.apache.commons.codec.digest.DigestUtils; import org.json.simple.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import win.liyufan.im.*; +import java.net.MalformedURLException; +import java.net.URL; import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; @@ -62,7 +65,6 @@ import static cn.wildfirechat.proto.ProtoConstants.PersistFlag.Transparent; import static cn.wildfirechat.proto.ProtoConstants.Platform.*; import static cn.wildfirechat.proto.ProtoConstants.UpdateUserInfoMask.*; import static io.moquette.BrokerConstants.*; -import static io.moquette.BrokerConstants.APPLICATION_SECRET_KEY; import static io.moquette.server.Constants.MAX_CHATROOM_MESSAGE_QUEUE; import static io.moquette.server.Constants.MAX_MESSAGE_QUEUE; import static cn.wildfirechat.pojos.MyInfoType.*; @@ -166,8 +168,6 @@ public class MemoryMessagesStore implements IMessagesStore { private Set mUserHideProperties = new HashSet<>(); - private String mApplicationSecretKey; - MemoryMessagesStore(Server server, DatabaseStore databaseStore) { m_Server = server; this.databaseStore = databaseStore; @@ -445,17 +445,6 @@ public class MemoryMessagesStore implements IMessagesStore { } catch (NumberFormatException e) { e.printStackTrace(); } - - try { - mApplicationSecretKey = server.getConfig().getProperty(APPLICATION_SECRET_KEY, "wfcapp1290secretkey"); - } catch (Exception e) { - e.printStackTrace(); - } - while (StringUtil.isNullOrEmpty(mApplicationSecretKey) || mApplicationSecretKey.length() < 16) { - mApplicationSecretKey += "w"; - mApplicationSecretKey += mApplicationSecretKey; - } - } private void printMissConfigLog(String config, String defaultValue) { @@ -3315,23 +3304,103 @@ public class MemoryMessagesStore implements IMessagesStore { return true; } + private String ensureSecretLength(String secret) { + while ( secret.length() < 16) { + secret += "w"; + secret += secret; + } + return secret; + } + + @Override - public String getApplicationToken(String fromUser, String applicationId) { - byte[] token = AES.AESEncrypt(fromUser + "?|?" + System.currentTimeMillis() + "?|?" + applicationId, mApplicationSecretKey); - return new String(Base64.getEncoder().encode(token)); + public String getApplicationAuthCode(String fromUser, String applicationId, int type, String host) { + String secret = null; + if(type == 0) { + WFCMessage.Robot robotData = getRobot(applicationId); + if(robotData != null && !StringUtil.isNullOrEmpty(robotData.getCallback()) && !StringUtil.isNullOrEmpty(robotData.getSecret())) { + try { + URL url = new URL(robotData.getCallback()); + if(url.getHost().equals(host)) { + secret = robotData.getSecret(); + } else { + LOG.warn("get application auth code error, request host is not the same host with callback host"); + } + } catch (MalformedURLException e) { + e.printStackTrace(); + } + } else { + String errorReason; + if(robotData == null) { + errorReason = "Robot not exist."; + } else if(StringUtil.isNullOrEmpty(robotData.getCallback())) { + errorReason = "Robot no callback address"; + } else { + errorReason = "Robot no secret"; + } + LOG.warn("get application auth code error, reason {}", errorReason); + } + } else if(type == 1) { + WFCMessage.ChannelInfo channelData = getChannelInfo(applicationId); + if(channelData != null && !StringUtil.isNullOrEmpty(channelData.getCallback()) && !StringUtil.isNullOrEmpty(channelData.getSecret())) { + try { + URL url = new URL(channelData.getCallback()); + if(url.getHost().equals(host)) { + secret = channelData.getSecret(); + } else { + LOG.warn("get application auth code error, request host is not the same host with callback host"); + } + } catch (MalformedURLException e) { + e.printStackTrace(); + } + } else { + String errorReason; + if(channelData == null) { + errorReason = "Channel not exist."; + } else if(StringUtil.isNullOrEmpty(channelData.getCallback())) { + errorReason = "Channel no callback address"; + } else { + errorReason = "Channel no secret"; + } + LOG.warn("get application auth code error, reason {}", errorReason); + } + } + + if(!StringUtil.isNullOrEmpty(secret)) { + secret = ensureSecretLength(secret); + byte[] token = AES.AESEncrypt(fromUser + "?|?" + System.currentTimeMillis() + "?|?" + applicationId + "?|?" + type, secret); + return new String(Base64.getEncoder().encode(token)); + } + + return null; } @Override - public String verifyApplicationToken(String token, String applicationId) { - byte[] data = Base64.getDecoder().decode(token); - data = AES.AESDecrypt(data, mApplicationSecretKey, true); + public String verifyApplicationAuthCode(String authCode, String applicationId, int type) { + String secret = null; + if(type == 0) { + WFCMessage.Robot robotData = getRobot(applicationId); + if(robotData != null && !StringUtil.isNullOrEmpty(robotData.getCallback()) && !StringUtil.isNullOrEmpty(robotData.getSecret())) { + secret = robotData.getSecret(); + } + } else if(type == 1) { + WFCMessage.ChannelInfo channelData = getChannelInfo(applicationId); + if(channelData != null && !StringUtil.isNullOrEmpty(channelData.getCallback()) && !StringUtil.isNullOrEmpty(channelData.getSecret())) { + secret = channelData.getSecret(); + } + } + + secret = ensureSecretLength(secret); + + byte[] data = Base64.getDecoder().decode(authCode); + data = AES.AESDecrypt(data, secret, true); if (data == null || data.length == 0) { return null; } else { String str = new String(data); String[] strArr = str.split("\\?\\|\\?"); - if (strArr.length == 3) { + if (strArr.length == 4) { if (applicationId.equals(strArr[2])) { long timestamp= Long.parseLong(strArr[1]); if(System.currentTimeMillis() - timestamp > 60*1000) { @@ -3344,6 +3413,40 @@ public class MemoryMessagesStore implements IMessagesStore { return null; } + @Override + public ErrorCode configApplication(String appId, int appType, long timestamp, String nonce, String signature) { + String secret; + if(System.currentTimeMillis()/1000 - timestamp > 300) { + return ErrorCode.ERROR_CODE_SIGN_EXPIRED; + } + + if(appType == ProtoConstants.ApplicationType.ApplicationType_Robot) { + WFCMessage.Robot robotData = getRobot(appId); + if(robotData != null) { + secret = robotData.getSecret(); + } else { + return ErrorCode.ERROR_CODE_NOT_EXIST; + } + } else if(appType == ProtoConstants.ApplicationType.ApplicationType_Channel) { + WFCMessage.ChannelInfo channelData = getChannelInfo(appId); + if(channelData != null) { + secret = channelData.getSecret(); + } else { + return ErrorCode.ERROR_CODE_NOT_EXIST; + } + } else { + LOG.error("Config application type only support 0 or 1"); + return ErrorCode.INVALID_PARAMETER; + } + + String str = nonce + "|" + appId + "|" + timestamp + "|" + secret; + String sign = DigestUtils.sha1Hex(str); + if(sign.equals(signature)) { + return ErrorCode.ERROR_CODE_SUCCESS; + } + + return ErrorCode.ERROR_CODE_AUTH_FAILURE; + } @Override public boolean isNewFriendWelcomeMessage() { diff --git a/broker/src/main/java/io/moquette/spi/IMessagesStore.java b/broker/src/main/java/io/moquette/spi/IMessagesStore.java index f6f4b470..d0231dfc 100755 --- a/broker/src/main/java/io/moquette/spi/IMessagesStore.java +++ b/broker/src/main/java/io/moquette/spi/IMessagesStore.java @@ -194,8 +194,9 @@ public interface IMessagesStore { boolean checkChatroomParticipantIdelTime(MemorySessionStore.Session session); - String getApplicationToken(String fromUser, String applicationId); - String verifyApplicationToken(String token, String applicationId); + String getApplicationAuthCode(String fromUser, String applicationId, int appType, String host); + String verifyApplicationAuthCode(String token, String applicationId, int type); + ErrorCode configApplication(String appId, int appType, long timestamp, String nonce, String signature); ErrorCode getUserSettings(String userId, long version, WFCMessage.GetUserSettingResult.Builder builder); WFCMessage.UserSettingEntry getUserSetting(String userId, int scope, String key); diff --git a/broker/src/main/java/win/liyufan/im/IMTopic.java b/broker/src/main/java/win/liyufan/im/IMTopic.java index 3adf2740..cc320966 100755 --- a/broker/src/main/java/win/liyufan/im/IMTopic.java +++ b/broker/src/main/java/win/liyufan/im/IMTopic.java @@ -85,4 +85,5 @@ public interface IMTopic { String ClearSessionTopic = "CST"; String GetApplicationTokenRequestTopic = "ATR"; + String ApplicationConfigRequestTopic = "ACR"; } diff --git a/common/src/main/java/cn/wildfirechat/common/APIPath.java b/common/src/main/java/cn/wildfirechat/common/APIPath.java index 94d2fc32..6f52dd1f 100644 --- a/common/src/main/java/cn/wildfirechat/common/APIPath.java +++ b/common/src/main/java/cn/wildfirechat/common/APIPath.java @@ -92,7 +92,7 @@ public interface APIPath { String Channel_Message_Send = "/channel/message/send"; String Channel_Subscribe = "/channel/subscribe"; String Channel_Subscriber_List = "/channel/subscriber_list"; - String Channel_Verify_Application_UserInfo = "/channel/user/verify"; + String Channel_Application_Get_UserInfo = "/channel/application/get_user_info"; String Robot_User_Info = "/robot/user_info"; String Robot_Get_Profile = "/robot/profile"; @@ -101,7 +101,7 @@ public interface APIPath { String Robot_Get_Callback = "/robot/get_callback"; String Robot_Delete_Callback = "/robot/delete_callback"; String Robot_Update_Profile = "/robot/update_profile"; - String Robot_Verify_Application_UserInfo = "/robot/user/verify"; + String Robot_Application_Get_UserInfo = "/robot/application/get_user_info"; String Robot_Group_Member_Add = "/robot/group/member/add"; String Robot_Group_Allow_Member = "/robot/group/manager/allow"; String Robot_Create_Group = "/robot/group/create"; diff --git a/common/src/main/java/cn/wildfirechat/pojos/InputVerifyApplicationUserInfo.java b/common/src/main/java/cn/wildfirechat/pojos/InputApplicationGetUserInfo.java similarity index 57% rename from common/src/main/java/cn/wildfirechat/pojos/InputVerifyApplicationUserInfo.java rename to common/src/main/java/cn/wildfirechat/pojos/InputApplicationGetUserInfo.java index 8d983cec..8c62c59b 100755 --- a/common/src/main/java/cn/wildfirechat/pojos/InputVerifyApplicationUserInfo.java +++ b/common/src/main/java/cn/wildfirechat/pojos/InputApplicationGetUserInfo.java @@ -8,14 +8,14 @@ package cn.wildfirechat.pojos; -public class InputVerifyApplicationUserInfo { - private String token; +public class InputApplicationGetUserInfo { + private String authCode; - public String getToken() { - return token; + public String getAuthCode() { + return authCode; } - public void setToken(String token) { - this.token = token; + public void setAuthCode(String authCode) { + this.authCode = authCode; } } diff --git a/common/src/main/java/cn/wildfirechat/pojos/OutputApplicationConfigData.java b/common/src/main/java/cn/wildfirechat/pojos/OutputApplicationConfigData.java new file mode 100755 index 00000000..d71a55e2 --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/OutputApplicationConfigData.java @@ -0,0 +1,57 @@ +/* + * This file is part of the Wildfire Chat package. + * (c) Heavyrain2012 + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +package cn.wildfirechat.pojos; + +public class OutputApplicationConfigData { + private String appId; + private int appType; + private long timestamp; + private String nonceStr; + private String signature; + + public String getAppId() { + return appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public int getAppType() { + return appType; + } + + public void setAppType(int appType) { + this.appType = appType; + } + + public long getTimestamp() { + return timestamp; + } + + public void setTimestamp(long timestamp) { + this.timestamp = timestamp; + } + + public String getNonceStr() { + return nonceStr; + } + + public void setNonceStr(String nonceStr) { + this.nonceStr = nonceStr; + } + + public String getSignature() { + return signature; + } + + public void setSignature(String signature) { + this.signature = signature; + } +} diff --git a/common/src/main/java/cn/wildfirechat/pojos/OutputVerifyApplicationUserInfo.java b/common/src/main/java/cn/wildfirechat/pojos/OutputApplicationUserInfo.java similarity index 94% rename from common/src/main/java/cn/wildfirechat/pojos/OutputVerifyApplicationUserInfo.java rename to common/src/main/java/cn/wildfirechat/pojos/OutputApplicationUserInfo.java index 032390a6..a3f7fc04 100755 --- a/common/src/main/java/cn/wildfirechat/pojos/OutputVerifyApplicationUserInfo.java +++ b/common/src/main/java/cn/wildfirechat/pojos/OutputApplicationUserInfo.java @@ -8,7 +8,7 @@ package cn.wildfirechat.pojos; -public class OutputVerifyApplicationUserInfo { +public class OutputApplicationUserInfo { private String userId; private String displayName; private String portraitUrl; diff --git a/common/src/main/java/cn/wildfirechat/pojos/OutputRobot.java b/common/src/main/java/cn/wildfirechat/pojos/OutputRobot.java old mode 100755 new mode 100644 index b93a7383..dc698261 --- a/common/src/main/java/cn/wildfirechat/pojos/OutputRobot.java +++ b/common/src/main/java/cn/wildfirechat/pojos/OutputRobot.java @@ -1,11 +1,3 @@ -/* - * This file is part of the Wildfire Chat package. - * (c) Heavyrain2012 - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - package cn.wildfirechat.pojos; diff --git a/common/src/main/java/cn/wildfirechat/proto/ProtoConstants.java b/common/src/main/java/cn/wildfirechat/proto/ProtoConstants.java index 35ed261e..e417b979 100644 --- a/common/src/main/java/cn/wildfirechat/proto/ProtoConstants.java +++ b/common/src/main/java/cn/wildfirechat/proto/ProtoConstants.java @@ -230,6 +230,11 @@ public class ProtoConstants { Request_From_Channel; } + public interface ApplicationType { + int ApplicationType_Robot = 0; + int ApplicationType_Channel = 1; + } + public static final int MESSAGE_CONTENT_TYPE_CREATE_GROUP = 104; public static final int MESSAGE_CONTENT_TYPE_ADD_GROUP_MEMBER = 105; public static final int MESSAGE_CONTENT_TYPE_KICKOF_GROUP_MEMBER = 106; diff --git a/common/src/main/java/cn/wildfirechat/proto/WFCMessage.java b/common/src/main/java/cn/wildfirechat/proto/WFCMessage.java index 296c4496..dd2f14ab 100644 --- a/common/src/main/java/cn/wildfirechat/proto/WFCMessage.java +++ b/common/src/main/java/cn/wildfirechat/proto/WFCMessage.java @@ -61789,6 +61789,1723 @@ public final class WFCMessage { // @@protoc_insertion_point(class_scope:RecallMultiCastMessageRequest) } + public interface AuthCodeRequestOrBuilder + extends com.google.protobuf.MessageOrBuilder { + + // required string target_id = 1; + /** + * required string target_id = 1; + */ + boolean hasTargetId(); + /** + * required string target_id = 1; + */ + java.lang.String getTargetId(); + /** + * required string target_id = 1; + */ + com.google.protobuf.ByteString + getTargetIdBytes(); + + // required int32 type = 2; + /** + * required int32 type = 2; + */ + boolean hasType(); + /** + * required int32 type = 2; + */ + int getType(); + + // required string host = 3; + /** + * required string host = 3; + */ + boolean hasHost(); + /** + * required string host = 3; + */ + java.lang.String getHost(); + /** + * required string host = 3; + */ + com.google.protobuf.ByteString + getHostBytes(); + } + /** + * Protobuf type {@code AuthCodeRequest} + */ + public static final class AuthCodeRequest extends + com.google.protobuf.GeneratedMessage + implements AuthCodeRequestOrBuilder { + // Use AuthCodeRequest.newBuilder() to construct. + private AuthCodeRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private AuthCodeRequest(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final AuthCodeRequest defaultInstance; + public static AuthCodeRequest getDefaultInstance() { + return defaultInstance; + } + + public AuthCodeRequest getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private AuthCodeRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + bitField0_ |= 0x00000001; + targetId_ = input.readBytes(); + break; + } + case 16: { + bitField0_ |= 0x00000002; + type_ = input.readInt32(); + break; + } + case 26: { + bitField0_ |= 0x00000004; + host_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return cn.wildfirechat.proto.WFCMessage.internal_static_AuthCodeRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return cn.wildfirechat.proto.WFCMessage.internal_static_AuthCodeRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + cn.wildfirechat.proto.WFCMessage.AuthCodeRequest.class, cn.wildfirechat.proto.WFCMessage.AuthCodeRequest.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public AuthCodeRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new AuthCodeRequest(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + // required string target_id = 1; + public static final int TARGET_ID_FIELD_NUMBER = 1; + private java.lang.Object targetId_; + /** + * required string target_id = 1; + */ + public boolean hasTargetId() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required string target_id = 1; + */ + public java.lang.String getTargetId() { + java.lang.Object ref = targetId_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + targetId_ = s; + } + return s; + } + } + /** + * required string target_id = 1; + */ + public com.google.protobuf.ByteString + getTargetIdBytes() { + java.lang.Object ref = targetId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + targetId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + // required int32 type = 2; + public static final int TYPE_FIELD_NUMBER = 2; + private int type_; + /** + * required int32 type = 2; + */ + public boolean hasType() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * required int32 type = 2; + */ + public int getType() { + return type_; + } + + // required string host = 3; + public static final int HOST_FIELD_NUMBER = 3; + private java.lang.Object host_; + /** + * required string host = 3; + */ + public boolean hasHost() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * required string host = 3; + */ + public java.lang.String getHost() { + java.lang.Object ref = host_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + host_ = s; + } + return s; + } + } + /** + * required string host = 3; + */ + public com.google.protobuf.ByteString + getHostBytes() { + java.lang.Object ref = host_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + host_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private void initFields() { + targetId_ = ""; + type_ = 0; + host_ = ""; + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + if (!hasTargetId()) { + memoizedIsInitialized = 0; + return false; + } + if (!hasType()) { + memoizedIsInitialized = 0; + return false; + } + if (!hasHost()) { + memoizedIsInitialized = 0; + return false; + } + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeBytes(1, getTargetIdBytes()); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + output.writeInt32(2, type_); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + output.writeBytes(3, getHostBytes()); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, getTargetIdBytes()); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(2, type_); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(3, getHostBytes()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static cn.wildfirechat.proto.WFCMessage.AuthCodeRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static cn.wildfirechat.proto.WFCMessage.AuthCodeRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static cn.wildfirechat.proto.WFCMessage.AuthCodeRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static cn.wildfirechat.proto.WFCMessage.AuthCodeRequest parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static cn.wildfirechat.proto.WFCMessage.AuthCodeRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static cn.wildfirechat.proto.WFCMessage.AuthCodeRequest parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static cn.wildfirechat.proto.WFCMessage.AuthCodeRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static cn.wildfirechat.proto.WFCMessage.AuthCodeRequest parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static cn.wildfirechat.proto.WFCMessage.AuthCodeRequest parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static cn.wildfirechat.proto.WFCMessage.AuthCodeRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(cn.wildfirechat.proto.WFCMessage.AuthCodeRequest prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code AuthCodeRequest} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements cn.wildfirechat.proto.WFCMessage.AuthCodeRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return cn.wildfirechat.proto.WFCMessage.internal_static_AuthCodeRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return cn.wildfirechat.proto.WFCMessage.internal_static_AuthCodeRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + cn.wildfirechat.proto.WFCMessage.AuthCodeRequest.class, cn.wildfirechat.proto.WFCMessage.AuthCodeRequest.Builder.class); + } + + // Construct using cn.wildfirechat.proto.WFCMessage.AuthCodeRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + targetId_ = ""; + bitField0_ = (bitField0_ & ~0x00000001); + type_ = 0; + bitField0_ = (bitField0_ & ~0x00000002); + host_ = ""; + bitField0_ = (bitField0_ & ~0x00000004); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return cn.wildfirechat.proto.WFCMessage.internal_static_AuthCodeRequest_descriptor; + } + + public cn.wildfirechat.proto.WFCMessage.AuthCodeRequest getDefaultInstanceForType() { + return cn.wildfirechat.proto.WFCMessage.AuthCodeRequest.getDefaultInstance(); + } + + public cn.wildfirechat.proto.WFCMessage.AuthCodeRequest build() { + cn.wildfirechat.proto.WFCMessage.AuthCodeRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public cn.wildfirechat.proto.WFCMessage.AuthCodeRequest buildPartial() { + cn.wildfirechat.proto.WFCMessage.AuthCodeRequest result = new cn.wildfirechat.proto.WFCMessage.AuthCodeRequest(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.targetId_ = targetId_; + if (((from_bitField0_ & 0x00000002) == 0x00000002)) { + to_bitField0_ |= 0x00000002; + } + result.type_ = type_; + if (((from_bitField0_ & 0x00000004) == 0x00000004)) { + to_bitField0_ |= 0x00000004; + } + result.host_ = host_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof cn.wildfirechat.proto.WFCMessage.AuthCodeRequest) { + return mergeFrom((cn.wildfirechat.proto.WFCMessage.AuthCodeRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(cn.wildfirechat.proto.WFCMessage.AuthCodeRequest other) { + if (other == cn.wildfirechat.proto.WFCMessage.AuthCodeRequest.getDefaultInstance()) return this; + if (other.hasTargetId()) { + bitField0_ |= 0x00000001; + targetId_ = other.targetId_; + onChanged(); + } + if (other.hasType()) { + setType(other.getType()); + } + if (other.hasHost()) { + bitField0_ |= 0x00000004; + host_ = other.host_; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + if (!hasTargetId()) { + + return false; + } + if (!hasType()) { + + return false; + } + if (!hasHost()) { + + return false; + } + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + cn.wildfirechat.proto.WFCMessage.AuthCodeRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (cn.wildfirechat.proto.WFCMessage.AuthCodeRequest) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + // required string target_id = 1; + private java.lang.Object targetId_ = ""; + /** + * required string target_id = 1; + */ + public boolean hasTargetId() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required string target_id = 1; + */ + public java.lang.String getTargetId() { + java.lang.Object ref = targetId_; + if (!(ref instanceof java.lang.String)) { + java.lang.String s = ((com.google.protobuf.ByteString) ref) + .toStringUtf8(); + targetId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * required string target_id = 1; + */ + public com.google.protobuf.ByteString + getTargetIdBytes() { + java.lang.Object ref = targetId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + targetId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * required string target_id = 1; + */ + public Builder setTargetId( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + targetId_ = value; + onChanged(); + return this; + } + /** + * required string target_id = 1; + */ + public Builder clearTargetId() { + bitField0_ = (bitField0_ & ~0x00000001); + targetId_ = getDefaultInstance().getTargetId(); + onChanged(); + return this; + } + /** + * required string target_id = 1; + */ + public Builder setTargetIdBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + targetId_ = value; + onChanged(); + return this; + } + + // required int32 type = 2; + private int type_ ; + /** + * required int32 type = 2; + */ + public boolean hasType() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * required int32 type = 2; + */ + public int getType() { + return type_; + } + /** + * required int32 type = 2; + */ + public Builder setType(int value) { + bitField0_ |= 0x00000002; + type_ = value; + onChanged(); + return this; + } + /** + * required int32 type = 2; + */ + public Builder clearType() { + bitField0_ = (bitField0_ & ~0x00000002); + type_ = 0; + onChanged(); + return this; + } + + // required string host = 3; + private java.lang.Object host_ = ""; + /** + * required string host = 3; + */ + public boolean hasHost() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * required string host = 3; + */ + public java.lang.String getHost() { + java.lang.Object ref = host_; + if (!(ref instanceof java.lang.String)) { + java.lang.String s = ((com.google.protobuf.ByteString) ref) + .toStringUtf8(); + host_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * required string host = 3; + */ + public com.google.protobuf.ByteString + getHostBytes() { + java.lang.Object ref = host_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + host_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * required string host = 3; + */ + public Builder setHost( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000004; + host_ = value; + onChanged(); + return this; + } + /** + * required string host = 3; + */ + public Builder clearHost() { + bitField0_ = (bitField0_ & ~0x00000004); + host_ = getDefaultInstance().getHost(); + onChanged(); + return this; + } + /** + * required string host = 3; + */ + public Builder setHostBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000004; + host_ = value; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:AuthCodeRequest) + } + + static { + defaultInstance = new AuthCodeRequest(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:AuthCodeRequest) + } + + public interface ApplicationConfigRequestOrBuilder + extends com.google.protobuf.MessageOrBuilder { + + // required string appId = 1; + /** + * required string appId = 1; + */ + boolean hasAppId(); + /** + * required string appId = 1; + */ + java.lang.String getAppId(); + /** + * required string appId = 1; + */ + com.google.protobuf.ByteString + getAppIdBytes(); + + // required int32 appType = 2; + /** + * required int32 appType = 2; + */ + boolean hasAppType(); + /** + * required int32 appType = 2; + */ + int getAppType(); + + // required int64 timestamp = 3; + /** + * required int64 timestamp = 3; + */ + boolean hasTimestamp(); + /** + * required int64 timestamp = 3; + */ + long getTimestamp(); + + // required string nonce = 4; + /** + * required string nonce = 4; + */ + boolean hasNonce(); + /** + * required string nonce = 4; + */ + java.lang.String getNonce(); + /** + * required string nonce = 4; + */ + com.google.protobuf.ByteString + getNonceBytes(); + + // required string signature = 5; + /** + * required string signature = 5; + */ + boolean hasSignature(); + /** + * required string signature = 5; + */ + java.lang.String getSignature(); + /** + * required string signature = 5; + */ + com.google.protobuf.ByteString + getSignatureBytes(); + } + /** + * Protobuf type {@code ApplicationConfigRequest} + */ + public static final class ApplicationConfigRequest extends + com.google.protobuf.GeneratedMessage + implements ApplicationConfigRequestOrBuilder { + // Use ApplicationConfigRequest.newBuilder() to construct. + private ApplicationConfigRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private ApplicationConfigRequest(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final ApplicationConfigRequest defaultInstance; + public static ApplicationConfigRequest getDefaultInstance() { + return defaultInstance; + } + + public ApplicationConfigRequest getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private ApplicationConfigRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + bitField0_ |= 0x00000001; + appId_ = input.readBytes(); + break; + } + case 16: { + bitField0_ |= 0x00000002; + appType_ = input.readInt32(); + break; + } + case 24: { + bitField0_ |= 0x00000004; + timestamp_ = input.readInt64(); + break; + } + case 34: { + bitField0_ |= 0x00000008; + nonce_ = input.readBytes(); + break; + } + case 42: { + bitField0_ |= 0x00000010; + signature_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return cn.wildfirechat.proto.WFCMessage.internal_static_ApplicationConfigRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return cn.wildfirechat.proto.WFCMessage.internal_static_ApplicationConfigRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + cn.wildfirechat.proto.WFCMessage.ApplicationConfigRequest.class, cn.wildfirechat.proto.WFCMessage.ApplicationConfigRequest.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public ApplicationConfigRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ApplicationConfigRequest(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + // required string appId = 1; + public static final int APPID_FIELD_NUMBER = 1; + private java.lang.Object appId_; + /** + * required string appId = 1; + */ + public boolean hasAppId() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required string appId = 1; + */ + public java.lang.String getAppId() { + java.lang.Object ref = appId_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + appId_ = s; + } + return s; + } + } + /** + * required string appId = 1; + */ + public com.google.protobuf.ByteString + getAppIdBytes() { + java.lang.Object ref = appId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + appId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + // required int32 appType = 2; + public static final int APPTYPE_FIELD_NUMBER = 2; + private int appType_; + /** + * required int32 appType = 2; + */ + public boolean hasAppType() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * required int32 appType = 2; + */ + public int getAppType() { + return appType_; + } + + // required int64 timestamp = 3; + public static final int TIMESTAMP_FIELD_NUMBER = 3; + private long timestamp_; + /** + * required int64 timestamp = 3; + */ + public boolean hasTimestamp() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * required int64 timestamp = 3; + */ + public long getTimestamp() { + return timestamp_; + } + + // required string nonce = 4; + public static final int NONCE_FIELD_NUMBER = 4; + private java.lang.Object nonce_; + /** + * required string nonce = 4; + */ + public boolean hasNonce() { + return ((bitField0_ & 0x00000008) == 0x00000008); + } + /** + * required string nonce = 4; + */ + public java.lang.String getNonce() { + java.lang.Object ref = nonce_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + nonce_ = s; + } + return s; + } + } + /** + * required string nonce = 4; + */ + public com.google.protobuf.ByteString + getNonceBytes() { + java.lang.Object ref = nonce_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + nonce_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + // required string signature = 5; + public static final int SIGNATURE_FIELD_NUMBER = 5; + private java.lang.Object signature_; + /** + * required string signature = 5; + */ + public boolean hasSignature() { + return ((bitField0_ & 0x00000010) == 0x00000010); + } + /** + * required string signature = 5; + */ + public java.lang.String getSignature() { + java.lang.Object ref = signature_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + signature_ = s; + } + return s; + } + } + /** + * required string signature = 5; + */ + public com.google.protobuf.ByteString + getSignatureBytes() { + java.lang.Object ref = signature_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + signature_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private void initFields() { + appId_ = ""; + appType_ = 0; + timestamp_ = 0L; + nonce_ = ""; + signature_ = ""; + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + if (!hasAppId()) { + memoizedIsInitialized = 0; + return false; + } + if (!hasAppType()) { + memoizedIsInitialized = 0; + return false; + } + if (!hasTimestamp()) { + memoizedIsInitialized = 0; + return false; + } + if (!hasNonce()) { + memoizedIsInitialized = 0; + return false; + } + if (!hasSignature()) { + memoizedIsInitialized = 0; + return false; + } + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeBytes(1, getAppIdBytes()); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + output.writeInt32(2, appType_); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + output.writeInt64(3, timestamp_); + } + if (((bitField0_ & 0x00000008) == 0x00000008)) { + output.writeBytes(4, getNonceBytes()); + } + if (((bitField0_ & 0x00000010) == 0x00000010)) { + output.writeBytes(5, getSignatureBytes()); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, getAppIdBytes()); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(2, appType_); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(3, timestamp_); + } + if (((bitField0_ & 0x00000008) == 0x00000008)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(4, getNonceBytes()); + } + if (((bitField0_ & 0x00000010) == 0x00000010)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(5, getSignatureBytes()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static cn.wildfirechat.proto.WFCMessage.ApplicationConfigRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static cn.wildfirechat.proto.WFCMessage.ApplicationConfigRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static cn.wildfirechat.proto.WFCMessage.ApplicationConfigRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static cn.wildfirechat.proto.WFCMessage.ApplicationConfigRequest parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static cn.wildfirechat.proto.WFCMessage.ApplicationConfigRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static cn.wildfirechat.proto.WFCMessage.ApplicationConfigRequest parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static cn.wildfirechat.proto.WFCMessage.ApplicationConfigRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static cn.wildfirechat.proto.WFCMessage.ApplicationConfigRequest parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static cn.wildfirechat.proto.WFCMessage.ApplicationConfigRequest parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static cn.wildfirechat.proto.WFCMessage.ApplicationConfigRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(cn.wildfirechat.proto.WFCMessage.ApplicationConfigRequest prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code ApplicationConfigRequest} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements cn.wildfirechat.proto.WFCMessage.ApplicationConfigRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return cn.wildfirechat.proto.WFCMessage.internal_static_ApplicationConfigRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return cn.wildfirechat.proto.WFCMessage.internal_static_ApplicationConfigRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + cn.wildfirechat.proto.WFCMessage.ApplicationConfigRequest.class, cn.wildfirechat.proto.WFCMessage.ApplicationConfigRequest.Builder.class); + } + + // Construct using cn.wildfirechat.proto.WFCMessage.ApplicationConfigRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + appId_ = ""; + bitField0_ = (bitField0_ & ~0x00000001); + appType_ = 0; + bitField0_ = (bitField0_ & ~0x00000002); + timestamp_ = 0L; + bitField0_ = (bitField0_ & ~0x00000004); + nonce_ = ""; + bitField0_ = (bitField0_ & ~0x00000008); + signature_ = ""; + bitField0_ = (bitField0_ & ~0x00000010); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return cn.wildfirechat.proto.WFCMessage.internal_static_ApplicationConfigRequest_descriptor; + } + + public cn.wildfirechat.proto.WFCMessage.ApplicationConfigRequest getDefaultInstanceForType() { + return cn.wildfirechat.proto.WFCMessage.ApplicationConfigRequest.getDefaultInstance(); + } + + public cn.wildfirechat.proto.WFCMessage.ApplicationConfigRequest build() { + cn.wildfirechat.proto.WFCMessage.ApplicationConfigRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public cn.wildfirechat.proto.WFCMessage.ApplicationConfigRequest buildPartial() { + cn.wildfirechat.proto.WFCMessage.ApplicationConfigRequest result = new cn.wildfirechat.proto.WFCMessage.ApplicationConfigRequest(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.appId_ = appId_; + if (((from_bitField0_ & 0x00000002) == 0x00000002)) { + to_bitField0_ |= 0x00000002; + } + result.appType_ = appType_; + if (((from_bitField0_ & 0x00000004) == 0x00000004)) { + to_bitField0_ |= 0x00000004; + } + result.timestamp_ = timestamp_; + if (((from_bitField0_ & 0x00000008) == 0x00000008)) { + to_bitField0_ |= 0x00000008; + } + result.nonce_ = nonce_; + if (((from_bitField0_ & 0x00000010) == 0x00000010)) { + to_bitField0_ |= 0x00000010; + } + result.signature_ = signature_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof cn.wildfirechat.proto.WFCMessage.ApplicationConfigRequest) { + return mergeFrom((cn.wildfirechat.proto.WFCMessage.ApplicationConfigRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(cn.wildfirechat.proto.WFCMessage.ApplicationConfigRequest other) { + if (other == cn.wildfirechat.proto.WFCMessage.ApplicationConfigRequest.getDefaultInstance()) return this; + if (other.hasAppId()) { + bitField0_ |= 0x00000001; + appId_ = other.appId_; + onChanged(); + } + if (other.hasAppType()) { + setAppType(other.getAppType()); + } + if (other.hasTimestamp()) { + setTimestamp(other.getTimestamp()); + } + if (other.hasNonce()) { + bitField0_ |= 0x00000008; + nonce_ = other.nonce_; + onChanged(); + } + if (other.hasSignature()) { + bitField0_ |= 0x00000010; + signature_ = other.signature_; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + if (!hasAppId()) { + + return false; + } + if (!hasAppType()) { + + return false; + } + if (!hasTimestamp()) { + + return false; + } + if (!hasNonce()) { + + return false; + } + if (!hasSignature()) { + + return false; + } + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + cn.wildfirechat.proto.WFCMessage.ApplicationConfigRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (cn.wildfirechat.proto.WFCMessage.ApplicationConfigRequest) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + // required string appId = 1; + private java.lang.Object appId_ = ""; + /** + * required string appId = 1; + */ + public boolean hasAppId() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required string appId = 1; + */ + public java.lang.String getAppId() { + java.lang.Object ref = appId_; + if (!(ref instanceof java.lang.String)) { + java.lang.String s = ((com.google.protobuf.ByteString) ref) + .toStringUtf8(); + appId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * required string appId = 1; + */ + public com.google.protobuf.ByteString + getAppIdBytes() { + java.lang.Object ref = appId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + appId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * required string appId = 1; + */ + public Builder setAppId( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + appId_ = value; + onChanged(); + return this; + } + /** + * required string appId = 1; + */ + public Builder clearAppId() { + bitField0_ = (bitField0_ & ~0x00000001); + appId_ = getDefaultInstance().getAppId(); + onChanged(); + return this; + } + /** + * required string appId = 1; + */ + public Builder setAppIdBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + appId_ = value; + onChanged(); + return this; + } + + // required int32 appType = 2; + private int appType_ ; + /** + * required int32 appType = 2; + */ + public boolean hasAppType() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * required int32 appType = 2; + */ + public int getAppType() { + return appType_; + } + /** + * required int32 appType = 2; + */ + public Builder setAppType(int value) { + bitField0_ |= 0x00000002; + appType_ = value; + onChanged(); + return this; + } + /** + * required int32 appType = 2; + */ + public Builder clearAppType() { + bitField0_ = (bitField0_ & ~0x00000002); + appType_ = 0; + onChanged(); + return this; + } + + // required int64 timestamp = 3; + private long timestamp_ ; + /** + * required int64 timestamp = 3; + */ + public boolean hasTimestamp() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * required int64 timestamp = 3; + */ + public long getTimestamp() { + return timestamp_; + } + /** + * required int64 timestamp = 3; + */ + public Builder setTimestamp(long value) { + bitField0_ |= 0x00000004; + timestamp_ = value; + onChanged(); + return this; + } + /** + * required int64 timestamp = 3; + */ + public Builder clearTimestamp() { + bitField0_ = (bitField0_ & ~0x00000004); + timestamp_ = 0L; + onChanged(); + return this; + } + + // required string nonce = 4; + private java.lang.Object nonce_ = ""; + /** + * required string nonce = 4; + */ + public boolean hasNonce() { + return ((bitField0_ & 0x00000008) == 0x00000008); + } + /** + * required string nonce = 4; + */ + public java.lang.String getNonce() { + java.lang.Object ref = nonce_; + if (!(ref instanceof java.lang.String)) { + java.lang.String s = ((com.google.protobuf.ByteString) ref) + .toStringUtf8(); + nonce_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * required string nonce = 4; + */ + public com.google.protobuf.ByteString + getNonceBytes() { + java.lang.Object ref = nonce_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + nonce_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * required string nonce = 4; + */ + public Builder setNonce( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000008; + nonce_ = value; + onChanged(); + return this; + } + /** + * required string nonce = 4; + */ + public Builder clearNonce() { + bitField0_ = (bitField0_ & ~0x00000008); + nonce_ = getDefaultInstance().getNonce(); + onChanged(); + return this; + } + /** + * required string nonce = 4; + */ + public Builder setNonceBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000008; + nonce_ = value; + onChanged(); + return this; + } + + // required string signature = 5; + private java.lang.Object signature_ = ""; + /** + * required string signature = 5; + */ + public boolean hasSignature() { + return ((bitField0_ & 0x00000010) == 0x00000010); + } + /** + * required string signature = 5; + */ + public java.lang.String getSignature() { + java.lang.Object ref = signature_; + if (!(ref instanceof java.lang.String)) { + java.lang.String s = ((com.google.protobuf.ByteString) ref) + .toStringUtf8(); + signature_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * required string signature = 5; + */ + public com.google.protobuf.ByteString + getSignatureBytes() { + java.lang.Object ref = signature_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + signature_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * required string signature = 5; + */ + public Builder setSignature( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000010; + signature_ = value; + onChanged(); + return this; + } + /** + * required string signature = 5; + */ + public Builder clearSignature() { + bitField0_ = (bitField0_ & ~0x00000010); + signature_ = getDefaultInstance().getSignature(); + onChanged(); + return this; + } + /** + * required string signature = 5; + */ + public Builder setSignatureBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000010; + signature_ = value; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:ApplicationConfigRequest) + } + + static { + defaultInstance = new ApplicationConfigRequest(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:ApplicationConfigRequest) + } + private static com.google.protobuf.Descriptors.Descriptor internal_static_AddFriendRequest_descriptor; private static @@ -62149,6 +63866,16 @@ public final class WFCMessage { private static com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_RecallMultiCastMessageRequest_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_AuthCodeRequest_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_AuthCodeRequest_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_ApplicationConfigRequest_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_ApplicationConfigRequest_fieldAccessorTable; public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { @@ -62322,8 +64049,12 @@ public final class WFCMessage { "ntent\030\002 \002(\0132\017.MessageContent\022\n\n\002to\030\003 \003(\t" + "\022\014\n\004line\030\004 \002(\005\"E\n\035RecallMultiCastMessage" + "Request\022\022\n\nmessage_id\030\001 \002(\003\022\020\n\010receiver\030" + - "\002 \003(\tB#\n\025cn.wildfirechat.protoB\nWFCMessa" + - "ge" + "\002 \003(\t\"@\n\017AuthCodeRequest\022\021\n\ttarget_id\030\001 " + + "\002(\t\022\014\n\004type\030\002 \002(\005\022\014\n\004host\030\003 \002(\t\"o\n\030Appli" + + "cationConfigRequest\022\r\n\005appId\030\001 \002(\t\022\017\n\007ap" + + "pType\030\002 \002(\005\022\021\n\ttimestamp\030\003 \002(\003\022\r\n\005nonce\030" + + "\004 \002(\t\022\021\n\tsignature\030\005 \002(\tB#\n\025cn.wildfirec" + + "hat.protoB\nWFCMessage" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { @@ -62762,6 +64493,18 @@ public final class WFCMessage { com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_RecallMultiCastMessageRequest_descriptor, new java.lang.String[] { "MessageId", "Receiver", }); + internal_static_AuthCodeRequest_descriptor = + getDescriptor().getMessageTypes().get(72); + internal_static_AuthCodeRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_AuthCodeRequest_descriptor, + new java.lang.String[] { "TargetId", "Type", "Host", }); + internal_static_ApplicationConfigRequest_descriptor = + getDescriptor().getMessageTypes().get(73); + internal_static_ApplicationConfigRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_ApplicationConfigRequest_descriptor, + new java.lang.String[] { "AppId", "AppType", "Timestamp", "Nonce", "Signature", }); return null; } }; diff --git a/distribution/src/main/resources/wildfirechat.conf b/distribution/src/main/resources/wildfirechat.conf index e3b4620f..8c7c15ec 100755 --- a/distribution/src/main/resources/wildfirechat.conf +++ b/distribution/src/main/resources/wildfirechat.conf @@ -103,9 +103,6 @@ message.global_mute_exception_types 401,402,403,404,405,407,408,410,411 ## 当为true时,不转发server api发送的消息;当为false时,转发server api发送的消息。 message.no_forward_admin_message false -## 应用密钥 -application.secret_key 123456 - ##禁止搜索用户 friend.disable_search false diff --git a/sdk/src/main/java/cn/wildfirechat/sdk/ChannelServiceApi.java b/sdk/src/main/java/cn/wildfirechat/sdk/ChannelServiceApi.java index 2e53f057..d0e26840 100644 --- a/sdk/src/main/java/cn/wildfirechat/sdk/ChannelServiceApi.java +++ b/sdk/src/main/java/cn/wildfirechat/sdk/ChannelServiceApi.java @@ -4,9 +4,13 @@ import cn.wildfirechat.common.APIPath; import cn.wildfirechat.pojos.*; import cn.wildfirechat.sdk.model.IMResult; import cn.wildfirechat.sdk.utilities.ChannelHttpUtils; +import org.apache.commons.codec.digest.DigestUtils; import java.util.List; +import static cn.wildfirechat.proto.ProtoConstants.ApplicationType.ApplicationType_Channel; +import static cn.wildfirechat.proto.ProtoConstants.ApplicationType.ApplicationType_Robot; + //仅专业版支持,社区版不支持 public class ChannelServiceApi { private final ChannelHttpUtils channelHttpUtils; @@ -76,12 +80,25 @@ public class ChannelServiceApi { return channelHttpUtils.httpJsonPost(path, null, OutputStringList.class); } + public IMResult applicationGetUserInfo(String authCode) throws Exception { + String path = APIPath.Channel_Application_Get_UserInfo; + InputApplicationGetUserInfo input = new InputApplicationGetUserInfo(); + input.setAuthCode(authCode); + return channelHttpUtils.httpJsonPost(path, input, OutputApplicationUserInfo.class); + } - public IMResult verifyApplicationUserInfo(String token) throws Exception { - String path = APIPath.Channel_Verify_Application_UserInfo; - InputVerifyApplicationUserInfo input = new InputVerifyApplicationUserInfo(); - input.setToken(token); - return channelHttpUtils.httpJsonPost(path, input, OutputVerifyApplicationUserInfo.class); + public OutputApplicationConfigData getApplicationSignature() { + int nonce = (int)(Math.random() * 100000 + 3); + long timestamp = System.currentTimeMillis()/1000; + String str = nonce + "|" + channelHttpUtils.getChannelId() + "|" + timestamp + "|" + channelHttpUtils.getChannelSecret(); + String sign = DigestUtils.sha1Hex(str); + OutputApplicationConfigData configData = new OutputApplicationConfigData(); + configData.setAppId(channelHttpUtils.getChannelId()); + configData.setAppType(ApplicationType_Channel); + configData.setTimestamp(timestamp); + configData.setNonceStr(nonce+""); + configData.setSignature(sign); + return configData; } } diff --git a/sdk/src/main/java/cn/wildfirechat/sdk/Main.java b/sdk/src/main/java/cn/wildfirechat/sdk/Main.java index 7210f42a..1db19bd3 100644 --- a/sdk/src/main/java/cn/wildfirechat/sdk/Main.java +++ b/sdk/src/main/java/cn/wildfirechat/sdk/Main.java @@ -1196,6 +1196,9 @@ public class Main { System.out.println("cancel group manager failure"); System.exit(-1); } + + OutputApplicationConfigData config = robotService.getApplicationSignature(); + System.out.println(config); } @@ -1422,6 +1425,8 @@ public class Main { System.out.println("get channel info failure"); System.exit(-1); } + OutputApplicationConfigData config = channelServiceApi.getApplicationSignature(); + System.out.println(config); } static void testSensitiveApi() throws Exception { List words = Arrays.asList("a","b","c"); diff --git a/sdk/src/main/java/cn/wildfirechat/sdk/RobotService.java b/sdk/src/main/java/cn/wildfirechat/sdk/RobotService.java index 75021f56..96a7ca3e 100644 --- a/sdk/src/main/java/cn/wildfirechat/sdk/RobotService.java +++ b/sdk/src/main/java/cn/wildfirechat/sdk/RobotService.java @@ -3,11 +3,13 @@ package cn.wildfirechat.sdk; import cn.wildfirechat.common.APIPath; import cn.wildfirechat.pojos.*; import cn.wildfirechat.sdk.model.IMResult; -import cn.wildfirechat.sdk.utilities.AdminHttpUtils; import cn.wildfirechat.sdk.utilities.RobotHttpUtils; +import org.apache.commons.codec.digest.DigestUtils; import java.util.List; +import static cn.wildfirechat.proto.ProtoConstants.ApplicationType.ApplicationType_Robot; + public class RobotService { private final RobotHttpUtils robotHttpUtils; @@ -216,11 +218,25 @@ public class RobotService { return robotHttpUtils.httpJsonPost(path, input, Void.class); } - public IMResult verifyApplicationUserInfo(String token) throws Exception { - String path = APIPath.Robot_Verify_Application_UserInfo; - InputVerifyApplicationUserInfo input = new InputVerifyApplicationUserInfo(); - input.setToken(token); - return robotHttpUtils.httpJsonPost(path, input, OutputVerifyApplicationUserInfo.class); + public IMResult applicationGetUserInfo(String authCode) throws Exception { + String path = APIPath.Robot_Application_Get_UserInfo; + InputApplicationGetUserInfo input = new InputApplicationGetUserInfo(); + input.setAuthCode(authCode); + return robotHttpUtils.httpJsonPost(path, input, OutputApplicationUserInfo.class); + } + + public OutputApplicationConfigData getApplicationSignature() { + int nonce = (int)(Math.random() * 100000 + 3); + long timestamp = System.currentTimeMillis()/1000; + String str = nonce + "|" + robotHttpUtils.getRobotId() + "|" + timestamp + "|" + robotHttpUtils.getRobotSecret(); + String sign = DigestUtils.sha1Hex(str); + OutputApplicationConfigData configData = new OutputApplicationConfigData(); + configData.setAppId(robotHttpUtils.getRobotId()); + configData.setAppType(ApplicationType_Robot); + configData.setTimestamp(timestamp); + configData.setNonceStr(nonce+""); + configData.setSignature(sign); + return configData; } diff --git a/sdk/src/main/java/cn/wildfirechat/sdk/utilities/ChannelHttpUtils.java b/sdk/src/main/java/cn/wildfirechat/sdk/utilities/ChannelHttpUtils.java index 0516d23b..eeae299d 100644 --- a/sdk/src/main/java/cn/wildfirechat/sdk/utilities/ChannelHttpUtils.java +++ b/sdk/src/main/java/cn/wildfirechat/sdk/utilities/ChannelHttpUtils.java @@ -115,4 +115,11 @@ public class ChannelHttpUtils { return str == null || str.isEmpty(); } + public String getChannelId() { + return channelId; + } + + public String getChannelSecret() { + return channelSecret; + } } diff --git a/sdk/src/main/java/cn/wildfirechat/sdk/utilities/RobotHttpUtils.java b/sdk/src/main/java/cn/wildfirechat/sdk/utilities/RobotHttpUtils.java index 426db648..523ae752 100644 --- a/sdk/src/main/java/cn/wildfirechat/sdk/utilities/RobotHttpUtils.java +++ b/sdk/src/main/java/cn/wildfirechat/sdk/utilities/RobotHttpUtils.java @@ -118,4 +118,11 @@ public class RobotHttpUtils { return str == null || str.isEmpty(); } + public String getRobotId() { + return robotId; + } + + public String getRobotSecret() { + return robotSecret; + } }