Type选择Static IP Address,IP Address/Host :填写南京海关端公网ip地址。Preshared Key和Prase 1 Proposal按照南京海关所发文档配置。
建立的第二阶段:
VPN Name:名称统一为vpn_to_customs_p2,Remote Gateway选中Predefied ,下拉列表中选择vpn_to_customs_p1,Prase 2 Proposal按照所发文档配置,Bind to 选中,并选新建的tunnel,proxy-ID选中,Local IP/Netmask填写客户端的ip网段和掩码,Romote IP/Netmask填写192.168.0.0/16,选中VPN Monitor即可。
4.路由配置
新建2条路由,第一条路由Network Address/Netmask填写0.0.0.0/0,选中Gateway ,Interface选择连接外网的端口号,Gateway IP Address填写该宽带的网关地址,点击OK按钮;第二条路由Network Address/Netmask填写192.168.0.0/16,选中Gateway ,Interface选择新建的tunnel,点击OK按钮。
5.策略配置
首先把any –any策略去除;从untrust到trust区域,源选择customs,目的选中local,service 选中any,logging选中;从trust区域到untrust,源选中local,目的选择customs,service 选中any,logging选中。
6.修改用户名口令 修改系统默认的用户名、口令。
11
四、报文传输软件参考程序片断 (一)签名
public static string SignXml(string xmlContent) { if (provider.ToLower() == \) { if (signaturer.ToLower() == \) { SignatureInterface.SignatureInterfacePortTypeClient sig = new MsgTrnsCommon.SignatureInterface.SignatureInterfacePortTypeClient(); return sig.getXMLSignature(ConfigurationManager.AppSettings[\], xmlContent); } else { return UniClient.XMLSignMQ(xmlContent); } } else if (provider.ToLower() == \) { if (signaturer.ToLower() == \) { JsServer.SetServer(ConfigurationManager.AppSettings[\],int.Parse(ConfigurationManager.AppSettings[\])); return JsServer.gtSignXmlString(xmlContent, ConfigurationManager.AppSettings[\]); } else { return JsClient.gtSignXmlString(xmlContent); } } else return string.Empty; } 12
(二) 验签
public static string VerifySign(string xmlContent) { if (provider.ToLower() == \) { if (verifier.ToLower() == \) { VerifySignature.VerifySignatureInterfacePortTypeClient ver = new MsgTrnsCommon.VerifySignature.VerifySignatureInterfacePortTypeClient(); return ver.xmlVerifySignature(xmlContent); } else { return UniClient.XMLVerifyMQSign(xmlContent); } } else if (provider.ToLower() == \) { if (verifier.ToLower() == \) { JsServer.SetServer(ConfigurationManager.AppSettings[\],int.Parse( ConfigurationManager.AppSettings[\])); return JsServer.gtVerifyXmlString(xmlContent); } else { UTF8Encoding ut = new UTF8Encoding(); Byte[] encodedBytes = ut.GetBytes(xmlContent); String decodedString = ut.GetString(encodedBytes); return JsClient.gtVerifyXmlString(decodedString); } } else return string.Empty; }
13
(三) 压缩
public static Stream Compress(Stream s) { s.Seek(0, SeekOrigin.Begin); MemoryStream cs = new MemoryStream(); try { DeflaterOutputStream cs1 = new DeflaterOutputStream(s, new Deflater(Deflater.BEST_COMPRESSION)); StreamCopy(cs, cs1, streamCopyBufferSize); } catch (Exception ex) { Logging.LogManager.GetLogger().Error(\压缩程序出错\, ex); throw ex; } cs.Seek(0, SeekOrigin.Begin); return cs; }
(四) 解压缩
public static Stream Decompress(Stream s) { InflaterInputStream inflaterInputStream = null; try { s.Seek(0, SeekOrigin.Begin); inflaterInputStream = new InflaterInputStream(s); } catch (Exception ex) { Logging.LogManager.GetLogger().Error(\解压缩出错\, ex); throw (new Exception(\出错函数\ + \ + ex.Message)); } return inflaterInputStream; }
(五) 字节数组与Base64的转换:
14
static void Main(string[] args) { string factString = \中华人民共和国\; byte[] myByte; string Base64Str; //先把字符串按照utf-8的编码转换成byte[] Encoding myEncoding = Encoding.GetEncoding(\); //myByte中获得这样的字节数组:228,184,173,229,141,142,228,186,186,230,176,145,229,133,177,229,146,140,229,155,189 myByte = myEncoding.GetBytes(factString); //把byte[]转成base64编码,这个例子形成的base64编码的unicode等价字符串为:\ Base64Str = Convert.ToBase64String(myByte); //再从base64编码转成byte[],又恢复为字节数组:228,184,173,229,141,142,228,186,186,230,176,145,229,133,177,229,146,140,229,155,189 myByte = Convert.FromBase64String(Base64Str); //用同一个Encoding对象把byte[]转成字符串:\中华人民共和国\ factString = myEncoding.GetString(myByte); Console.WriteLine(factString); }
注:以上程序片断不作为报文传输软件开发依据,仅供开发时参考。
15
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库南京海关物流监控信息化管理系统(3)在线全文阅读。
相关推荐: