Class: UnionPei::AcpService
- Inherits:
-
Object
- Object
- UnionPei::AcpService
- Defined in:
- lib/unionpei/acp_service.rb
Class Method Summary collapse
- .createAutoFormHtml(params, reqUrl) ⇒ Object
- .deCodeFileContent(params, fileDirectory) ⇒ Object
- .decryptData(data, certPath = SDKConfig.instance.signCertPath, certPwd = SDKConfig.instance.signCertPwd) ⇒ Object
- .enCodeFileContent(path) ⇒ Object
- .encryptData(data, certPath = SDKConfig.instance.encryptCertPath) ⇒ Object
- .getCustomerInfo(customerInfo) ⇒ Object
- .getCustomerInfoWithEncrypt(customerInfo) ⇒ Object
- .getEncryptCertId ⇒ Object
- .parseCustomerInfo(customerInfostr, certPath = SDKConfig.instance.signCertPath, certPwd = SDKConfig.instance.signCertPwd) ⇒ Object
- .post(params, url) ⇒ Object
- .sign(req, certPath = SDKConfig.instance.signCertPath, certPwd = SDKConfig.instance.signCertPwd) ⇒ Object
- .signByCertInfo(req, certPath, certPwd) ⇒ Object
- .signBySecureKey(req, secureKey) ⇒ Object
- .updateEncryptCert(params) ⇒ Object
- .validate(resp) ⇒ Object
- .validateBySecureKey(resp, secureKey) ⇒ Object
Class Method Details
.createAutoFormHtml(params, reqUrl) ⇒ Object
37 38 39 |
# File 'lib/unionpei/acp_service.rb', line 37 def self.createAutoFormHtml(params, reqUrl) SDKUtil.createAutoFormHtml(params, reqUrl) end |
.deCodeFileContent(params, fileDirectory) ⇒ Object
89 90 91 |
# File 'lib/unionpei/acp_service.rb', line 89 def self.deCodeFileContent(params, fileDirectory) SDKUtil.deCodeFileContent(params, fileDirectory) end |
.decryptData(data, certPath = SDKConfig.instance.signCertPath, certPwd = SDKConfig.instance.signCertPwd) ⇒ Object
85 86 87 |
# File 'lib/unionpei/acp_service.rb', line 85 def self.decryptData(data, certPath = SDKConfig.instance.signCertPath, certPwd = SDKConfig.instance.signCertPwd) SDKUtil.decryptPri(data, certPath, certPwd) end |
.enCodeFileContent(path) ⇒ Object
93 94 95 |
# File 'lib/unionpei/acp_service.rb', line 93 def self.enCodeFileContent(path) SDKUtil.enCodeFileContent(path) end |
.encryptData(data, certPath = SDKConfig.instance.encryptCertPath) ⇒ Object
81 82 83 |
# File 'lib/unionpei/acp_service.rb', line 81 def self.encryptData(data, certPath = SDKConfig.instance.encryptCertPath) SDKUtil.encryptPub(data, certPath) end |
.getCustomerInfo(customerInfo) ⇒ Object
41 42 43 44 45 |
# File 'lib/unionpei/acp_service.rb', line 41 def self.getCustomerInfo(customerInfo) return '' if customerInfo.nil? || customerInfo.length.zero? Base.encode64("{#{SDKUtil.createLinkString(customerInfo, false, false)}}").gsub(/\n|\r/, '') end |
.getCustomerInfoWithEncrypt(customerInfo) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/unionpei/acp_service.rb', line 47 def self.getCustomerInfoWithEncrypt(customerInfo) return '' if customerInfo.nil? || customerInfo.length.zero? encryptedInfo = {} customerInfo.each_key do |key| encryptedInfo[key] = customerInfo.delete(key) if (key == 'phoneNo') || (key == 'cvn2') || (key == 'expired') end if encryptedInfo.length.positive? encryptedInfo = SDKUtil.createLinkString(encryptedInfo, false, false) encryptedInfo = AcpService.encryptData(encryptedInfo, SDKConfig.instance.encryptCertPath) customerInfo['encryptedInfo'] = encryptedInfo end Base64.encode64("{#{SDKUtil.createLinkString(customerInfo, false, false)}}").gsub(/\n|\r/, '') end |
.getEncryptCertId ⇒ Object
77 78 79 |
# File 'lib/unionpei/acp_service.rb', line 77 def self.getEncryptCertId CertUtil.getEncryptCertId end |
.parseCustomerInfo(customerInfostr, certPath = SDKConfig.instance.signCertPath, certPwd = SDKConfig.instance.signCertPwd) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/unionpei/acp_service.rb', line 62 def self.parseCustomerInfo(customerInfostr, certPath = SDKConfig.instance.signCertPath, certPwd = SDKConfig.instance.signCertPwd) customerInfostr = Base64.decode64(customerInfostr) customerInfostr = customerInfostr[1, customerInfostr.length - 1] customerInfo = SDKUtil.parseQString(customerInfostr) if customerInfo['encryptedInfo'] encryptedInfoStr = customerInfo.delete('encryptedInfo') encryptedInfoStr = AcpService.decryptData(encryptedInfoStr, certPath, certPwd) encryptedInfo = SDKUtil.parseQString(encryptedInfoStr) encryptedInfo.each_key do |key| customerInfo[key] = encryptedInfo[key] end end customerInfo end |
.post(params, url) ⇒ Object
31 32 33 34 35 |
# File 'lib/unionpei/acp_service.rb', line 31 def self.post(params, url) content = SDKUtil.createLinkString(params, false, true) respString = SDKUtil.post(url, content) SDKUtil.parseQString(respString) end |
.sign(req, certPath = SDKConfig.instance.signCertPath, certPwd = SDKConfig.instance.signCertPwd) ⇒ Object
11 12 13 |
# File 'lib/unionpei/acp_service.rb', line 11 def self.sign(req, certPath = SDKConfig.instance.signCertPath, certPwd = SDKConfig.instance.signCertPwd) SDKUtil.buildSignature(req, certPath, certPwd) end |
.signByCertInfo(req, certPath, certPwd) ⇒ Object
15 16 17 |
# File 'lib/unionpei/acp_service.rb', line 15 def self.signByCertInfo(req, certPath, certPwd) SDKUtil.buildSignature(req, certPath, certPwd) end |
.signBySecureKey(req, secureKey) ⇒ Object
19 20 21 |
# File 'lib/unionpei/acp_service.rb', line 19 def self.signBySecureKey(req, secureKey) SDKUtil.buildSignature(req, nil, nil, secureKey) end |
.updateEncryptCert(params) ⇒ Object
97 98 99 |
# File 'lib/unionpei/acp_service.rb', line 97 def self.updateEncryptCert(params) SDKUtil.getEncryptCert(params) end |
.validate(resp) ⇒ Object
23 24 25 |
# File 'lib/unionpei/acp_service.rb', line 23 def self.validate(resp) SDKUtil.verify(resp) end |
.validateBySecureKey(resp, secureKey) ⇒ Object
27 28 29 |
# File 'lib/unionpei/acp_service.rb', line 27 def self.validateBySecureKey(resp, secureKey) SDKUtil.verifyBySecureKey(resp, secureKey) end |