Class: UnionPei::AcpService

Inherits:
Object
  • Object
show all
Defined in:
lib/unionpei/acp_service.rb

Class Method Summary collapse

Class Method Details

.createAutoFormHtml(params, reqUrl) ⇒ Object



38
39
40
# File 'lib/unionpei/acp_service.rb', line 38

def AcpService.createAutoFormHtml(params, reqUrl)
  return SDKUtil.createAutoFormHtml(params, reqUrl)
end

.deCodeFileContent(params, fileDirectory) ⇒ Object



94
95
96
# File 'lib/unionpei/acp_service.rb', line 94

def AcpService.deCodeFileContent(params, fileDirectory)
    return SDKUtil.deCodeFileContent(params, fileDirectory)
end

.decryptData(data, certPath = SDKConfig.instance.signCertPath, certPwd = SDKConfig.instance.signCertPwd) ⇒ Object



90
91
92
# File 'lib/unionpei/acp_service.rb', line 90

def AcpService.decryptData(data, certPath=SDKConfig.instance.signCertPath, certPwd=SDKConfig.instance.signCertPwd)
    return SDKUtil.decryptPri(data, certPath, certPwd)
end

.enCodeFileContent(path) ⇒ Object



98
99
100
# File 'lib/unionpei/acp_service.rb', line 98

def AcpService.enCodeFileContent(path)
    return SDKUtil.enCodeFileContent(path)
end

.encryptData(data, certPath = SDKConfig.instance.encryptCertPath) ⇒ Object



86
87
88
# File 'lib/unionpei/acp_service.rb', line 86

def AcpService.encryptData(data, certPath=SDKConfig.instance.encryptCertPath)
    return SDKUtil.encryptPub(data, certPath)
end

.getCustomerInfo(customerInfo) ⇒ Object



42
43
44
45
46
47
# File 'lib/unionpei/acp_service.rb', line 42

def AcpService.getCustomerInfo(customerInfo)
  if(customerInfo == nil or customerInfo.length == 0)
      return ""
  end
  return Base.encode64("{" + SDKUtil.createLinkString(customerInfo,false,false)+"}").gsub(/\n|\r/, '')
end

.getCustomerInfoWithEncrypt(customerInfo) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/unionpei/acp_service.rb', line 49

def AcpService.getCustomerInfoWithEncrypt(customerInfo)
  if(customerInfo == nil or customerInfo.length == 0)
    return ""
  end
  encryptedInfo = {}
  for key in customerInfo.keys
    if (key == 'phoneNo' or key == 'cvn2' or key == 'expired')
      encryptedInfo[key] = customerInfo.delete(key)
    end
  end
  if (encryptedInfo.length > 0)
    encryptedInfo = SDKUtil.createLinkString(encryptedInfo, false, false)
    encryptedInfo = AcpService.encryptData(encryptedInfo, SDKConfig.instance.encryptCertPath)
    customerInfo['encryptedInfo'] = encryptedInfo
  end
  return Base64.encode64("{" + SDKUtil.createLinkString(customerInfo,false,false)+"}").gsub(/\n|\r/, '')
end

.getEncryptCertIdObject



82
83
84
# File 'lib/unionpei/acp_service.rb', line 82

def AcpService.getEncryptCertId
  return CertUtil.getEncryptCertId
end

.parseCustomerInfo(customerInfostr, certPath = SDKConfig.instance.signCertPath, certPwd = SDKConfig.instance.signCertPwd) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/unionpei/acp_service.rb', line 67

def AcpService.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)
    for key in encryptedInfo.keys
      customerInfo[key] = encryptedInfo[key]
    end
  end
  return customerInfo
end

.post(params, url) ⇒ Object



31
32
33
34
35
36
# File 'lib/unionpei/acp_service.rb', line 31

def AcpService.post(params, url)
  content = SDKUtil.createLinkString(params, false, true)
  respString = SDKUtil.post(url, content)
  resp = SDKUtil.parseQString(respString)
  return resp
end

.sign(req, certPath = SDKConfig.instance.signCertPath, certPwd = SDKConfig.instance.signCertPwd) ⇒ Object



11
12
13
# File 'lib/unionpei/acp_service.rb', line 11

def AcpService.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 AcpService.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 AcpService.signBySecureKey(req, secureKey)
  SDKUtil.buildSignature(req, nil, nil, secureKey)
end

.updateEncryptCert(params) ⇒ Object



102
103
104
# File 'lib/unionpei/acp_service.rb', line 102

def AcpService.updateEncryptCert(params)
    return SDKUtil.getEncryptCert(params)
end

.validate(resp) ⇒ Object



23
24
25
# File 'lib/unionpei/acp_service.rb', line 23

def AcpService.validate(resp)
  SDKUtil.verify(resp)
end

.validateBySecureKey(resp, secureKey) ⇒ Object



27
28
29
# File 'lib/unionpei/acp_service.rb', line 27

def AcpService.validateBySecureKey(resp, secureKey)
  SDKUtil.verifyBySecureKey(resp, secureKey)
end