新浪支付
原文:http://blog.csdn.net/lzlovez/article/details/51167286
1.接口介入方式
这种接口介入的方式,各大平台都差不多的,支付宝啊,微信支付啊,融宝支付啊,银盈通啊。都是系统必要的参数,和接口需要的参数,拼一起然互加密。
新浪支付生成 sign 的方式,签名的方式可以是 RSA 的加密方式和 MD5 的加密的方式,不过新浪推荐的是MD5的加密方式,但是给的demo里面是RSA的方式,所有自己用的也会是RSA的加密方式。
简单的例子 创建激活会员
[java]view plaincopy
- publicstaticSinaPayresponsecreateActivateMember(Map<String,Object>data)throwsException{
- SinaPayResponseresponse=newSinaPayResponse();
- if(data==null||data.size()==0){
- response.setCode(ResponceCodeEnum.Missingparameter.getCode());
- response.setERRORMsg("传入的参数为空");
- returnresponse;
- }
- //用户标识信息
- if(data.get("identity_id")==null||data.get("identity_id").equals("")){
- response.setCode(ResponceCodeEnum.MissingParameter.getCode());
- response.setErrorMsg("传入的参数:用户标识信息(identity_id)为空");
- returnresponse;
- }
- Map<String,Object>map=newHashMap<String,Object>();
- map.put("identity_id",data.get("identity_id"));
- //用户标识类型,目前只支持UID
- map.put("identity_type",SinaPayConfig.IDENTITY_TYPE);
- //1:个人会员;2:企业会员。默认是1
- if(data.get("member_type")!=null&&!data.get("member_type").equals("")){
- map.put("member_type",data.get("member_type"));
- }
- //系统参数
- map.put("service",SinaPayConfig.CREATE_ACTIVATE_MEMBER);
- Stringstr=SinaUtils.createLinkString(map,true);
- Stringres="";
- try{
- res=CallServiceUtil.sendPost(SinaPayConfig.MEMBER_TSET_URL,str);
- }catch(Exceptione){
- response.setCode(ResponceCodeEnum.connectionTimedOut.getCode());
- response.setErrorMsg("请求超时");
- returnresponse;
- }
- Stringresult=URLDecoder.decode(res,SinaUtils.CHARSET);
- Map<String,String>resultMap=GsonUtil.fronJson2Map(result);
- if(SinaPayConfig.APPLY_SUCCESS.equals(resultMap.get("response_code"))){//成功
- response.setCode(ResponceCodeEnum.success.getCode());
- response.setErrorMsg("请求成功");
- response.setResponseMap(resultMap);
- returnresponse;
- }else{
- response.setCode(ResponceCodeEnum.requestFails.getCode());
- response.setErrorMsg(resultMap.get("response_message"));
- response.setResponseMap(resultMap);
- returnresponse;
- }
- }
String str = SinaUtils.createLinkString(map, true);这一步是在吧我们需要的参数,包括 系统的参数,也包括接口需要的参数,生成 待签名的 字符串
[java]view plaincopy
- /**
- *把参数重新排序下
- *
- *@parammap
- *@paramb
- *@return
- *@throwsException
- */
- publicstaticStringcreateLinkString(Map<String,Object>map,booleanencode)throwsException{
- map.put("version",SinaPayConfig.VERSION);
- map.put("request_time",SinaTimeUtils.getTime());
- map.put("partner_id",SinaPayConfig.PARTNER_ID);
- map.put("_input_charset",SinaUtils.CHARSET);
- Stringcontent=SinaUtils.getContent(map);
- map.put("sign",SinaUtils.getSign(content));
- map.put("sign_type",SinaPayConfig.SIGN_TYPE);
- List<String>keys=newArrayList<String>(map.keySet());
- collections.sort(keys);
- Stringprestr="";
- Stringcharset=(String)map.get("_input_charset");
- for(inti=0;i<keys.size();i++){
- Stringkey=keys.get(i);
- Stringvalue=(String)map.get(key);
- if(encode){
- try{
- value=URLEncoder.encode(URLEncoder.encode(value,charset),charset);
- }catch(UnsupportedEncodingExceptione){
- e.printstacktrace();
- }
- }
- if(i==keys.size()-1){
- prestr=prestr+key+"="+value;
- }else{
- prestr=prestr+key+"="+value+"&";
- }
- }
- returnprestr;
- }
res = CallServiceUtil.sendPost(SinaPayConfig.MEMBER_TSET_URL, str); 这一步是在请求接口,返回结果
[java]view plaincopy
- publicstaticStringsendPost(Stringurl,Stringparam){
- printwriterout=null;
- BufferedReaderin=null;
- Stringresult="";
- try{
- URLrealUrl=newURL(url);
- URLConnectionconn=realUrl.openConnection();
- conn.setrequestproperty("accept","*/*");
- conn.setRequestProperty("connection","Keep-Alive");
- conn.setRequestProperty("user-agent","Mozilla/4.0(compatible;MSIE6.0;windowsNT5.1;SV1)");
- conn.setDoOutput(true);
- conn.setDoInput(true);
- out=newPrintWriter(conn.getoutputstream());
- out.print(param);
- out.flush();
- in=newBufferedReader(newinputstreamreader(conn.getInputStream()));
- Stringline;
- while((line=in.readLine())!=null){
- result+=line;
- }
- }catch(Exceptione){
- System.out.println("POST请求异常:"+e);
- e.printStackTrace();
- }finally{
- try{
- if(out!=null){
- out.close();
- }
- if(in!=null){
- in.close();
- }
- }catch(IOExceptionex){
- ex.printStackTrace();
- }
- }
- returnresult;
- }
这个时候返回的结果是经过URLencode的代码,所以需要 处理下
String result = URLDecoder.decode(res, SinaUtils.CHARSET);
Map<String, String> resultMap = GsonUtil.fronJson2Map(result); 这一步是在把得到的结果的传,转成Map
[java]view plaincopy
- publicstatic<T>TfronJson2Map(Stringjson){
- returngson.fromJson(json,newTypeToken<Map<String,String>>(){
- }.getType());
- }
大部分的接口都是这样的调用的方式,有些接口需要的一些参数涉及用户的隐私,所以需要对参数进行RSA加密
[java]view plaincopy
- /**
- *比如一些参数需要加密的话
- *
- *@paramstring待加密的信息
- *@throwsException
- *@throws
- */
- publicstaticStringgetRSAEncodeDoc(Stringdata)throwsException{
- byte[]data_byte=RSA.encryptByPublicKey(data.getBytes(CHARSET),SinaPayConfig.ENCRYPT);
- returnbase64.encode(data_byte);
- }
这个是 RSA 的类
[java]view plaincopy
- packagecom.sinapay.util;
- importjava.io.ByteArrayOutputStream;
- importjava.io.UnsupportedEncodingException;
- importjava.security.InvalidKeyException;
- importjava.security.Key;
- importjava.security.KeyFactory;
- importjava.security.KeyPair;
- importjava.security.KeyPairGenerator;
- importjava.security.NoSuchAlgorithmException;
- importjava.security.PrivateKey;
- importjava.security.PublicKey;
- importjava.security.Signature;
- importjava.security.SignatureException;
- importjava.security.cert.Certificate;
- importjava.security.interfaces.RSAPrivateKey;
- importjava.security.interfaces.RSAPublicKey;
- importjava.security.spec.PKCS8EncodedKeySpec;
- importjava.security.spec.X509EncodedKeySpec;
- importjava.util.HashMap;
- importjava.util.Map;
- importjavax.crypto.Cipher;
- importorg.apache.commons.codec.binary.Base64;
- /**
- *
- *<p>RSA签名,加解密处理核心文件,注意:密钥长度1024</p>
- *@authorleelun
- *@version$Id:RSA.java,v0.12013-11-15下午2:33:53lilunExp$
- */
- publicclassRSA{
- /**
- *签名算法
- */
- publicstaticfinalStringSIGNATURE_ALGORITHM="SHA1withRSA";
- /**
- *加密算法RSA
- */
- publicstaticfinalStringKEY_ALGORITHM="RSA";
- /**
- *RSA最大加密明文大小
- */
- privatestaticfinalintMAX_ENCRYPT_BLOCK=117;
- /**
- *RSA最大解密密文大小
- */
- privatestaticfinalintMAX_DECRYPT_BLOCK=128;
- /**
- *获取公钥的key
- */
- privatestaticfinalStringPUBLIC_KEY="RSAPublicKey";
- /**
- *获取私钥的key
- */
- privatestaticfinalStringPRIVATE_KEY="RSAPrivateKey";
- /**
- *<p>
- *生成密钥对(公钥和私钥)
- *</p>
- *
- *@return
- *@throwsException
- */
- publicstaticMap<String,Object>genKeyPair()throwsException{
- KeyPairGeneratorkeyPairGen=KeyPairGenerator.getinstance(KEY_ALGORITHM);
- keyPairGen.initialize(1024);
- KeyPairkeyPair=keyPairGen.generateKeyPair();
- RSAPublicKeypublicKey=(RSAPublicKey)keyPair.getPublic();
- RSAPrivateKeyprivateKey=(RSAPrivateKey)keyPair.getPrivate();
- Map<String,Object>keyMap=newHashMap<String,Object>(2);
- keyMap.put(PUBLIC_KEY,publicKey);
- keyMap.put(PRIVATE_KEY,privateKey);
- returnkeyMap;
- }
- publicstaticvoidmain(String[]args)throwsException{
- Map<String,Object>genKeyPair=genKeyPair();
- Stringbase64publicKey=getPublicKey(genKeyPair);
- System.out.println("公钥\n"+base64publicKey);
- Stringbase64privateKey=getPrivateKey(genKeyPair);
- System.out.println("私钥\n"+base64privateKey);
- Stringpasswd="cat123113";
- StringcharsetName="utf-8";
- StringencryptByPublicKey=Base64.encodeBase64String((encryptByPublicKey(
- passwd.getBytes(charsetName),base64publicKey)));
- System.out.println("加密\n"+encryptByPublicKey);
- byte[]decryptByPrivateKey=decryptByPrivateKey(Base64.decodeBase64(encryptByPublicKey),
- base64privateKey);
- Stringstring=newString(decryptByPrivateKey,"utf-8");
- System.out.println("解密后\n"+string);
- }
- /**
- *签名字符串
- *
- *@paramtext
- *需要签名的字符串
- *@paramprivateKey私钥(BASE64编码)
- *
- *@paramcharset
- *编码格式
- *@return签名结果(BASE64编码)
- */
- publicstaticStringsign(Stringtext,StringprivateKey,Stringcharset)throwsException{
- byte[]keyBytes=Base64.decodeBase64(privateKey);
- PKCS8EncodedKeySpecpkcs8KeySpec=newPKCS8EncodedKeySpec(keyBytes);
- KeyFactorykeyFactory=KeyFactory.getInstance(KEY_ALGORITHM);
- PrivateKeyprivateK=keyFactory.generatePrivate(pkcs8KeySpec);
- Signaturesignature=Signature.getInstance(SIGNATURE_ALGORITHM);
- signature.initSign(privateK);
- signature.update(getContentBytes(text,charset));
- byte[]result=signature.sign();
- returnBase64.encodeBase64String(result);
- }
- publicstaticStringsign(Stringtext,PrivateKeyprivateKey,Stringcharset)
- throwsSignatureException,
- InvalidKeyException{
- try{
- Signaturesignature=Signature.getInstance(SIGNATURE_ALGORITHM);
- signature.initSign(privateKey);
- signature.update(getContentBytes(text,charset));
- byte[]result=signature.sign();
- returnBase64.encodeBase64String(result);
- }catch(NoSuchAlgorithmExceptione){
- //不可能发生,
- returnnull;
- }
- }
- /**
- *签名字符串
- *
- *@paramtext
- *需要签名的字符串
- *@paramsign
- *客户签名结果
- *@parampublicKey
- *公钥(BASE64编码)
- *@paramcharset
- *编码格式
- *@return验签结果
- */
- publicstaticbooleanverify(Stringtext,Stringsign,StringpublicKey,Stringcharset)
- throwsException{
- byte[]keyBytes=Base64.decodeBase64(publicKey);
- X509EncodedKeySpeckeySpec=newX509EncodedKeySpec(keyBytes);
- KeyFactorykeyFactory=KeyFactory.getInstance(KEY_ALGORITHM);
- PublicKeypublicK=keyFactory.generatePublic(keySpec);
- Signaturesignature=Signature.getInstance(SIGNATURE_ALGORITHM);
- signature.initVerify(publicK);
- signature.update(getContentBytes(text,charset));
- returnsignature.verify(Base64.decodeBase64(sign));
- }
- /**
- *<P>
- *私钥解密
- *</p>
- *
- *@paramencryptedData已加密数据
- *@paramprivateKey私钥(BASE64编码)
- *@return
- *@throwsException
- */
- publicstaticbyte[]decryptByPrivateKey(byte[]encryptedData,StringprivateKey)
- throwsException{
- byte[]keyBytes=Base64.decodeBase64(privateKey);
- PKCS8EncodedKeySpecpkcs8KeySpec=newPKCS8EncodedKeySpec(keyBytes);
- KeyFactorykeyFactory=KeyFactory.getInstance(KEY_ALGORITHM);
- KeyprivateK=keyFactory.generatePrivate(pkcs8KeySpec);
- Ciphercipher=Cipher.getInstance(keyFactory.getAlgorithm());
- cipher.init(Cipher.DECRYPT_MODE,privateK);
- intinputLen=encryptedData.length;
- ByteArrayOutputStreamout=newByteArrayOutputStream();
- intoffset=0;
- byte[]cache;
- inti=0;
- //对数据分段解密
- while(inputLen-offSet>0){
- if(inputLen-offSet>MAX_DECRYPT_BLOCK){
- cache=cipher.doFinal(encryptedData,offSet,MAX_DECRYPT_BLOCK);
- }else{
- cache=cipher.doFinal(encryptedData,offSet,inputLen-offSet);
- }
- out.write(cache,0,cache.length);
- i++;
- offSet=i*MAX_DECRYPT_BLOCK;
- }
- byte[]decryptedData=out.toByteArray();
- out.close();
- returndecryptedData;
- }
- /**
- *<p>
- *公钥解密
- *</p>
- *
- *@paramencryptedData已加密数据
- *@parampublicKey公钥(BASE64编码)
- *@return
- *@throwsException
- */
- publicstaticbyte[]decryptByPublicKey(byte[]encryptedData,StringpublicKey)
- throwsException{
- byte[]keyBytes=Base64.decodeBase64(publicKey);
- X509EncodedKeySpecx509KeySpec=newX509EncodedKeySpec(keyBytes);
- KeyFactorykeyFactory=KeyFactory.getInstance(KEY_ALGORITHM);
- KeypublicK=keyFactory.generatePublic(x509KeySpec);
- Ciphercipher=Cipher.getInstance(keyFactory.getAlgorithm());
- cipher.init(Cipher.DECRYPT_MODE,publicK);
- intinputLen=encryptedData.length;
- ByteArrayOutputStreamout=newByteArrayOutputStream();
- intoffSet=0;
- byte[]cache;
- inti=0;
- //对数据分段解密
- while(inputLen-offSet>0){
- if(inputLen-offSet>MAX_DECRYPT_BLOCK){
- cache=cipher.doFinal(encryptedData,offSet,MAX_DECRYPT_BLOCK);
- }else{
- cache=cipher.doFinal(encryptedData,offSet,inputLen-offSet);
- }
- out.write(cache,0,cache.length);
- i++;
- offSet=i*MAX_DECRYPT_BLOCK;
- }
- byte[]decryptedData=out.toByteArray();
- out.close();
- returndecryptedData;
- }
- /**
- *<p>
- *公钥加密
- *</p>
- *
- *@parAMData源数据
- *@parampublicKey公钥(BASE64编码)
- *@return
- *@throwsException
- */
- publicstaticbyte[]encryptByPublicKey(byte[]data,StringpublicKey)throwsException{
- byte[]keyBytes=Base64.decodeBase64(publicKey);
- X509EncodedKeySpecx509KeySpec=newX509EncodedKeySpec(keyBytes);
- KeyFactorykeyFactory=KeyFactory.getInstance(KEY_ALGORITHM);
- KeypublicK=keyFactory.generatePublic(x509KeySpec);
- //对数据加密
- Ciphercipher=Cipher.getInstance(keyFactory.getAlgorithm());
- cipher.init(Cipher.ENCRYPT_MODE,publicK);
- intinputLen=data.length;
- ByteArrayOutputStreamout=newByteArrayOutputStream();
- intoffSet=0;
- byte[]cache;
- inti=0;
- //对数据分段加密
- while(inputLen-offSet>0){
- if(inputLen-offSet>MAX_ENCRYPT_BLOCK){
- cache=cipher.doFinal(data,offSet,MAX_ENCRYPT_BLOCK);
- }else{
- cache=cipher.doFinal(data,offSet,inputLen-offSet);
- }
- out.write(cache,0,cache.length);
- i++;
- offSet=i*MAX_ENCRYPT_BLOCK;
- }
- byte[]encryptedData=out.toByteArray();
- out.close();
- returnencryptedData;
- }
- /**
- *<p>
- *公钥加密
- *</p>
- *
- *@paramdata源数据
- *@paramcert证书
- *@return
- *@throwsException
- */
- publicstaticbyte[]encryptByPublicKey(byte[]data,Certificatecert)throwsException{
- //对数据加密
- PublicKeyuk=cert.getPublicKey();
- Ciphercipher=Cipher.getInstance(uk.getAlgorithm());
- cipher.init(Cipher.ENCRYPT_MODE,uk);
- intinputLen=data.length;
- ByteArrayOutputStreamout=newByteArrayOutputStream();
- intoffSet=0;
- byte[]cache;
- inti=0;
- //对数据分段加密
- while(inputLen-offSet>0){
- if(inputLen-offSet>MAX_ENCRYPT_BLOCK){
- cache=cipher.doFinal(data,offSet,MAX_ENCRYPT_BLOCK);
- }else{
- cache=cipher.doFinal(data,offSet,inputLen-offSet);
- }
- out.write(cache,0,cache.length);
- i++;
- offSet=i*MAX_ENCRYPT_BLOCK;
- }
- byte[]encryptedData=out.toByteArray();
- out.close();
- returnencryptedData;
- }
- /**
- *<p>
- *私钥加密
- *</p>
- *
- *@paramdata源数据
- *@paramprivateKey私钥(BASE64编码)
- *@return
- *@throwsException
- */
- publicstaticbyte[]encryptByPrivateKey(byte[]data,StringprivateKey)throwsException{
- byte[]keyBytes=Base64.decodeBase64(privateKey);
- PKCS8EncodedKeySpecpkcs8KeySpec=newPKCS8EncodedKeySpec(keyBytes);
- KeyFactorykeyFactory=KeyFactory.getInstance(KEY_ALGORITHM);
- KeyprivateK=keyFactory.generatePrivate(pkcs8KeySpec);
- Ciphercipher=Cipher.getInstance(keyFactory.getAlgorithm());
- cipher.init(Cipher.ENCRYPT_MODE,privateK);
- intinputLen=data.length;
- ByteArrayOutputStreamout=newByteArrayOutputStream();
- intoffSet=0;
- byte[]cache;
- inti=0;
- //对数据分段加密
- while(inputLen-offSet>0){
- if(inputLen-offSet>MAX_ENCRYPT_BLOCK){
- cache=cipher.doFinal(data,offSet,MAX_ENCRYPT_BLOCK);
- }else{
- cache=cipher.doFinal(data,offSet,inputLen-offSet);
- }
- out.write(cache,0,cache.length);
- i++;
- offSet=i*MAX_ENCRYPT_BLOCK;
- }
- byte[]encryptedData=out.toByteArray();
- out.close();
- returnencryptedData;
- }
- /**
- *@paramcontent
- *@paramcharset
- *@return
- *@throwsSignatureException
- *@throwsUnsupportedEncodingException
- */
- privatestaticbyte[]getContentBytes(Stringcontent,Stringcharset){
- if(charset==null||"".equals(charset)){
- returncontent.getBytes();
- }
- try{
- returncontent.getBytes(charset);
- }catch(UnsupportedEncodingExceptione){
- thrownewruntimeexception("签名过程中出现错误,指定的编码集不对,您目前指定的编码集是:"+charset);
- }
- }
- /**
- *<p>
- *获取私钥
- *</p>
- *
- *@paramkeyMap密钥对
- *@return
- *@throwsException
- */
- publicstaticStringgetPrivateKey(Map<String,Object>keyMap)throwsException{
- Keykey=(Key)keyMap.get(PRIVATE_KEY);
- returnBase64.encodeBase64String(key.getEncoded());
- }
- /**
- *<p>
- *获取公钥
- *</p>
- *
- *@paramkeyMap密钥对
- *@return
- *@throwsException
- */
- publicstaticStringgetPublicKey(Map<String,Object>keyMap)throwsException{
- Keykey=(Key)keyMap.get(PUBLIC_KEY);
- returnBase64.encodeBase64String(key.getEncoded());
- }
- }
大概就是这么多了,可能还有些要注意的地方
1.在请求审核企业会员资质(audit_member_infos)中需要上传 一个zip的压缩包,里面需要的内容都是定好了的,比如上传了8个文件,每个文件都以名称和后缀的形式放在一起,然后压缩成zip包,zip包的命名和 这个接口需要的传的参数 fileName 要一样,然后,用工具类,对zip包进行 MD5 摘要计算,计算的代码
[java]view plaincopy
- publicstaticStringgetFileMD5(Filefile){
- if(!file.isFile()){
- returnnull;
- }
- MessageDigestdigest=null;
- fileinputstreamin=null;
- bytebuffer[]=newbyte[1024];
- intlen;
- try{
- digest=MessageDigest.getInstance("MD5");
- in=newFileInputStream(file);
- while((len=in.read(buffer,0,1024))!=-1){
- digest.update(buffer,0,len);
- }
- in.close();
- }catch(Exceptione){
- e.printStackTrace();
- returnnull;
- }
[java]view plaincopy
- Stringfile_path=data.get("file_path").toString();
- Filefile=newFile(file_path);
- Stringfilemd5=Tools.getFileMD5(file);
- System.out.println(filemd5);
- System.out.println("-------------------------start------------------------------");
- System.out.println("链接sftp");
- sftps=newsftp();
- try{
- s.upload("/upload/",file_path,s.connectSFTP());
- System.out.print("sftp文件上传成功!");
- s.ls("/upload/",s.connectSFTP());
- }catch(SftpExceptione){
- e.printStackTrace();
- System.out.print("sftp文件上传失败!");
- response.setCode(ResponceCodeEnum.fileUploadFail.getCode());
- response.setErrorMsg("sftp文件上传失败!");
- returnresponse;
- }
- System.out.println("sftp关闭");
- System.out.println("-------------------------end------------------------------");
sftp 类
[java]view plaincopy
- packagecom.sinapay.util;
- importjava.io.File;
- importjava.io.FileInputStream;
- importjava.util.Properties;
- importjava.util.vector;
- importcom.jcraft.jsch.Channel;
- importcom.jcraft.jsch.ChannelSftp;
- importcom.jcraft.jsch.JSch;
- importcom.jcraft.jsch.JSchException;
- importcom.jcraft.jsch.session;
- importcom.jcraft.jsch.SftpException;
- publicclasssftp{
- protectedStringhost="";//新浪的给的服务器地址
- protectedStringusername="";//用户名
- protectedStringpassword;
- protectedStringprivateKey="c:\\data\\id_rsa";//秘钥的位置
- protectedStringpassphrase;
- protectedintport=50022;//端口
- publicChannelSftpconnectSFTP(){
- JSchjsch=newJSch();
- Channelchannel=null;
- try{
- if(privateKey!=null&&!"".equals(privateKey)){
- if(passphrase!=null&&"".equals(passphrase)){
- jsch.addIdentity(privateKey,passphrase);
- }else{
- jsch.addIdentity(privateKey);
- }
- }
- Sessionsession=jsch.getSession(username,host,port);
- if(password!=null&&!"".equals(password)){
- session.setPassword(password);
- }
- PropertiessshConfig=newProperties();
- sshConfig.put("StrictHostKeyChecking","no");//donotverifyhostkey
- session.setConfig(sshConfig);
- session.setServerAliveInterval(92000);
- session.connect();
- channel=session.openChannel("sftp");
- channel.connect();
- }catch(JSchExceptione){
- e.printStackTrace();
- }
- return(ChannelSftp)channel;
- }
- publicvoidupload(Stringdirectory,StringuploadFile,ChannelSftpsftp){
- try{
- sftp.cd(directory);
- Filefile=newFile(uploadFile);
- sftp.put(newFileInputStream(file),file.getName());
- }catch(Exceptione){
- e.printStackTrace();
- }
- }
- @SuppressWarnings("rawtypes")
- publicvoidls(Stringdirectory,ChannelSftpsftp)throwsSftpException{
- sftp.cd(directory);
- Vectorv=sftp.ls("*.*");
- for(inti=0;i<v.size();i++){
- System.out.println(v.get(i));
- }
- }
- publicvoiddownload(Stringdirectory,StringdownloadFile,StringsaveFile,ChannelSftpsftp){
- try{
- sftp.cd(directory);
- sftp.get(downloadFile,saveFile);
- }catch(Exceptione){
- e.printStackTrace();
- }
- }
- publicvoiddelete(Stringdirectory,StringdeleteFile,ChannelSftpsftp){
- try{
- sftp.cd(directory);
- sftp.rm(deleteFile);
- }catch(Exceptione){
- e.printStackTrace();
- }
- }
- publicvoiddisconnected(ChannelSftpsftp){
- if(sftp!=null){
- try{
- sftp.getSession().disconnect();
- }catch(JSchExceptione){
- e.printStackTrace();
- }
- sftp.disconnect();
- }
- }
- }
其他的都是接口调用了,都没啥了。
相关阅读
接口对接分为两种形式: 我方A公司提供接口给B公司,B公司进行一些操作时调用我们的接口进行实现。 例:A开发会员等级同步接口,供B同步
今天要分享的内容,会以商家的视角去分析对接渠道过程中需要关注的问题。一. 支付渠道业务规则这部分内容主要介绍常见支付渠道的业
因为项目的需求,所以对于支付这块,对接的企业支付宝的电脑网站支付和手机支付。写这篇博客的主要目的就是想把支付这块的对接给详细
一直以来天猫能提供的只有买卖行为缺乏品牌建设,当商品在不同平台都能买到的时候,天猫的差异化在哪?除了价格战天猫还能做什么?未来
在使用机顶盒遥控器的操作电视机时电视机遥控器和机顶盒遥控器不通用,这样用起来十分不方便,我们可能要一手拿电视机遥控器一手拿机