⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 phslogin.java

📁 JAVA实现的短信网关程序
💻 JAVA
字号:
package sms.PHS;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2004</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class PHSLogin extends PHSRequest{   static final int COMMAND_ID = 1;   String authenticatorSP;   static final int lenAuthenticatorSP = 16;  //客户端密码用于鉴别客户端的接入请求。其值通过单向MD5 hash计算得出,   static final int lenLoginMode = 1;        //登录类型(0=发送短消息, 1=接收短消息,2=收发短消息,其他保留)登录类型(0=发送短消息, 1=接收短消息,2=收发短消息,其他保留)   static final int lenMessageBody = 30;   static final int lenSourceAddr = 8;   static final int lenTimestamp = 4;       //时间戳的明文,由客户端产生,格式为MMDDHHMMSS,即月日时分秒,10位数字的整型,右对齐   static final int lenVersion = 1;         //客户端支持的版本号(高位4bit表示主版本号,低位4bit表示次版本号)   byte loginMode;   String sourceAddr;   int timestamp;   byte version;    public PHSLogin(String SourceAddr, String AuthenticatorSP, byte loginMode, byte Version)        throws PHSException    {        super(1);        this.loginMode = 0;  //0=发送短消息,        timestamp = 0;        version = 0;        setClientId(SourceAddr);        setAuthenticatorSP(AuthenticatorSP);        setVersion(Version);        setLoginMode(loginMode);        setTimestamp();    }    /**     *     * @param SequenceId : 序列号(由客户端分配,循环递增)     * @param SourceAddr     * @param AuthenticatorSP     * @param loginMode     * @param Version     * @throws PHSException     */    public PHSLogin(int SequenceId, String SourceAddr, String AuthenticatorSP, byte loginMode, byte Version)        throws PHSException    {        super(1, SequenceId);        this.loginMode = 0;        timestamp = 0;        version = 0;        setClientId(SourceAddr);        setAuthenticatorSP(AuthenticatorSP);        setVersion(Version);        setLoginMode(loginMode);        setTimestamp();    }    public void encodePacket(PHSIO cmppio)        throws PHSException    {        if(sourceAddr == null)            throw new PHSException("encodePacket : Source_Addr is null !");        if(authenticatorSP == null)            throw new PHSException("encodePacket : AuthenticatorSP is null !");        byte spaceString[] = {0, 0, 0, 0, 0, 0, 0};        //md5加密        byte md5authenticatorSP[] =            PHSUtil.hash(sourceAddr + new String(spaceString) + authenticatorSP + PHSUtil.zeroPadString(String.valueOf(timestamp), 10));        insertByte(version);        insertInteger(timestamp);        insertByte(loginMode);        insertBytes(md5authenticatorSP);        insertString(sourceAddr, 8);        if(getLength() != 30)        {            throw new PHSException("encodePacket : \u6570\u636E\u5305\u957F\u5EA6\u4E0D\u6B63\u786E !");        } else        {            super.encodePacket(cmppio);            return;        }    }    public String getAuthenticatorSP()        throws PHSException    {        return authenticatorSP;    }    public String getSourceAddr()        throws PHSException    {        return sourceAddr;    }    public int getTimestamp()        throws PHSException    {        return timestamp;    }    public byte getVersion()        throws PHSException    {        return version;    }    public void setAuthenticatorSP(String AuthenticatorSP)        throws PHSException    {        if(AuthenticatorSP == null)        {            throw new PHSException("setAuthenticatorSP : AuthenticatorSP is null !");        } else        {            authenticatorSP = AuthenticatorSP;            return;        }    }    public void setClientId(String SourceAddr)        throws PHSException    {        if(SourceAddr == null)        {            throw new PHSException("setSource_Addr : Source_Addr is null !");        } else        {            sourceAddr = SourceAddr;            return;        }    }    public void setLoginMode(byte loginMode)        throws PHSException    {        this.loginMode = loginMode;    }    private void setTimestamp()        throws PHSException    {        timestamp = PHSUtil.getTimestamp();    }    public void setVersion(byte Version)        throws PHSException    {        version = Version;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -