use of com.zx.sms.codec.cmpp.msg.CmppConnectRequestMessage in project SMSGate by Lihuanghe.
the class SessionLoginManager method failedLogin.
@Override
protected /**
* 状态 0:正确 1:消息结构错 2:非法源地址 3:认证错 4:版本太高 5~ :其他错误
*/
void failedLogin(ChannelHandlerContext ctx, Object msg, long status) {
if (msg instanceof CmppConnectRequestMessage) {
logger.error("Connected error status :{},msg : {}", status, msg);
CmppConnectRequestMessage message = (CmppConnectRequestMessage) msg;
// 认证失败
CmppConnectResponseMessage resp = new CmppConnectResponseMessage(message.getHeader().getSequenceId());
resp.setAuthenticatorISMG(new byte[16]);
resp.setStatus(status);
ChannelFuture promise = ctx.writeAndFlush(resp);
final ChannelHandlerContext finalctx = ctx;
promise.addListener(new GenericFutureListener() {
public void operationComplete(Future future) throws Exception {
finalctx.close();
}
});
} else {
logger.error("connect msg type error : {}", msg);
ctx.close();
}
}
use of com.zx.sms.codec.cmpp.msg.CmppConnectRequestMessage in project SMSGate by Lihuanghe.
the class SessionLoginManager method doLogin.
@Override
protected void doLogin(Channel ch) {
CMPPEndpointEntity cliententity = (CMPPEndpointEntity) entity;
CmppConnectRequestMessage req = new CmppConnectRequestMessage();
req.setSourceAddr(cliententity.getUserName());
String timestamp = DateFormatUtils.format(CachedMillisecondClock.INS.now(), "MMddHHmmss");
req.setTimestamp(Long.parseLong(timestamp));
byte[] userBytes = cliententity.getUserName().getBytes(cliententity.getChartset());
byte[] passwdBytes = cliententity.getPassword().getBytes(cliententity.getChartset());
byte[] timestampBytes = timestamp.getBytes(cliententity.getChartset());
req.setAuthenticatorSource(DigestUtils.md5(Bytes.concat(userBytes, new byte[9], passwdBytes, timestampBytes)));
req.setVersion(cliententity.getVersion());
ch.writeAndFlush(req);
logger.info("session Start :Send CmppConnectRequestMessage seq :{}", req.getHeader().getSequenceId());
}
Aggregations