Class: KakaocertService

Inherits:
BarocertService show all
Defined in:
lib/barocert/kakaocert.rb

Overview

kakaocert API BaseService class

Constant Summary

Constants inherited from BarocertService

BarocertService::APIVersion, BarocertService::BOUNDARY, BarocertService::ServiceID_REAL, BarocertService::ServiceURL, BarocertService::ServiceURL_Static

Instance Attribute Summary

Attributes inherited from BarocertService

#ipRestrictOnOff, #linkhub, #scopes, #token_table, #useLocalTimeYN, #useStaticIP

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BarocertService

#addScope, #getServiceURL, #getSession_Token, #gzip_parse, #httpget, #httppost, #setAuthURL, #setIpRestrictOnOff, #setServiceURL, #setUseLocalTimeYN, #setUseStaticIP, #sha256Base64urlFile

Class Method Details

.instance(linkID, secretKey) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/barocert/kakaocert.rb', line 10

def instance(linkID, secretKey)
	super(linkID, secretKey)
	@instance ||= new
	@instance.addScope("401")
	@instance.addScope("402")
	@instance.addScope("403")
	@instance.addScope("404")
	@instance.addScope("405")
	return @instance
end

Instance Method Details

#_encrypt(plaintext) ⇒ Object



27
28
29
# File 'lib/barocert/kakaocert.rb', line 27

def _encrypt(plaintext)
	return aes256gcm(plaintext, @linkhub._secretKey)
end

#_sha256_base64url_file(target) ⇒ Object



23
24
25
# File 'lib/barocert/kakaocert.rb', line 23

def _sha256_base64url_file(target)
	return self.sha256Base64urlFile(target)
end

#aes256gcm(plaintext, key) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/barocert/kakaocert.rb', line 31

def aes256gcm(plaintext, key)
	iv = OpenSSL::Random.random_bytes(12)
	cipher = OpenSSL::Cipher.new('aes-256-gcm')
	cipher.encrypt
	cipher.key = Base64.decode64(key)
	cipher.iv = iv
	ciphertext = cipher.update(plaintext) + cipher.final
	return Base64.strict_encode64(iv + ciphertext + cipher.auth_tag)
end

#getCMSStatus(clientCode, receiptID) ⇒ Object



398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
# File 'lib/barocert/kakaocert.rb', line 398

def getCMSStatus(clientCode, receiptID)
	if clientCode.to_s == ''
		raise BarocertException.new('-99999999', '이용기관코드가 입력되지 않았습니다.')
	end
	if clientCode.is_i? == false
		raise BarocertException.new('-99999999', '이용기관코드는 숫자만 입력할 수 있습니다.')
	end
	if clientCode.length != 12
		raise BarocertException.new('-99999999', '이용기관코드는 12자 입니다.')
	end
	if receiptID.to_s == ''
		raise BarocertException.new('-99999999', '접수아이디가 입력되지 않았습니다.')
	end
	if receiptID.is_i? == false
		raise BarocertException.new('-99999999', '접수아이디는 숫자만 입력할 수 있습니다.')
	end
	if receiptID.length != 32
		raise BarocertException.new('-99999999', '접수아이디는 32자 입니다.')
	end

	httpget("/KAKAO/CMS/#{clientCode}/#{receiptID}")
end

#getIdentityStatus(clientCode, receiptID) ⇒ Object



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/barocert/kakaocert.rb', line 114

def getIdentityStatus(clientCode, receiptID)
	puts receiptID
	if clientCode.to_s == ''
		raise BarocertException.new('-99999999', '이용기관코드가 입력되지 않았습니다.')
	end
	if clientCode.is_i? == false
		raise BarocertException.new('-99999999', '이용기관코드는 숫자만 입력할 수 있습니다.')
	end
	if clientCode.length != 12
		raise BarocertException.new('-99999999', '이용기관코드는 12자 입니다.')
	end
	if receiptID.to_s == ''
		raise BarocertException.new('-99999999', '접수아이디가 입력되지 않았습니다.')
	end
	if receiptID.is_i? == false
		raise BarocertException.new('-99999999', '접수아이디는 숫자만 입력할 수 있습니다.')
	end
	if receiptID.length != 32
		raise BarocertException.new('-99999999', '접수아이디는 32자 입니다.')
	end

	httpget("/KAKAO/Identity/#{clientCode}/#{receiptID}")
end

#getMultiSignStatus(clientCode, receiptID) ⇒ Object



294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
# File 'lib/barocert/kakaocert.rb', line 294

def getMultiSignStatus(clientCode, receiptID)
	if clientCode.to_s == ''
		raise BarocertException.new('-99999999', '이용기관코드가 입력되지 않았습니다.')
	end
	if clientCode.is_i? == false
		raise BarocertException.new('-99999999', '이용기관코드는 숫자만 입력할 수 있습니다.')
	end
	if clientCode.length != 12
		raise BarocertException.new('-99999999', '이용기관코드는 12자 입니다.')
	end
	if receiptID.to_s == ''
		raise BarocertException.new('-99999999', '접수아이디가 입력되지 않았습니다.')
	end
	if receiptID.is_i? == false
		raise BarocertException.new('-99999999', '접수아이디는 숫자만 입력할 수 있습니다.')
	end
	if receiptID.length != 32
		raise BarocertException.new('-99999999', '접수아이디는 32자 입니다.')
	end

	httpget("/KAKAO/MultiSign/#{clientCode}/#{receiptID}")
end

#getSignStatus(clientCode, receiptID) ⇒ Object



202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
# File 'lib/barocert/kakaocert.rb', line 202

def getSignStatus(clientCode, receiptID)
	if clientCode.to_s == ''
		raise BarocertException.new('-99999999', '이용기관코드가 입력되지 않았습니다.')
	end
	if clientCode.is_i? == false
		raise BarocertException.new('-99999999', '이용기관코드는 숫자만 입력할 수 있습니다.')
	end
	if clientCode.length != 12
		raise BarocertException.new('-99999999', '이용기관코드는 12자 입니다.')
	end
	if receiptID.to_s == ''
		raise BarocertException.new('-99999999', '접수아이디가 입력되지 않았습니다.')
	end
	if receiptID.is_i? == false
		raise BarocertException.new('-99999999', '접수아이디는 숫자만 입력할 수 있습니다.')
	end
	if receiptID.length != 32
		raise BarocertException.new('-99999999', '접수아이디는 32자 입니다.')
	end

	httpget("/KAKAO/Sign/#{clientCode}/#{receiptID}")
end

#isNullorEmptyTitle(tokens) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/barocert/kakaocert.rb', line 45

def isNullorEmptyTitle(tokens)
	if tokens.nil?
		return true
	end
	tokens.each{ |token|
		if token.nil?
			return true
		end
		if token["signTitle"].to_s == '' && token["reqTitle"].to_s == ''
			return true
		end
	}
	false
end

#isNullorEmptyToken(tokens) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/barocert/kakaocert.rb', line 60

def isNullorEmptyToken(tokens)
	if tokens.nil?
		return true
	end
	tokens.each{ |token|
		if token.nil?
			return true
		end
		if token["token"].to_s == ''
			return true
		end
	}
	false
end

#isNumber(str) ⇒ Object



41
42
43
# File 'lib/barocert/kakaocert.rb', line 41

def isNumber(str)
	return str.is_i?
end

#requestCMS(clientCode, cms) ⇒ Object



340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
# File 'lib/barocert/kakaocert.rb', line 340

def requestCMS(clientCode, cms)
	if clientCode.to_s == ''
		raise BarocertException.new('-99999999', '이용기관코드가 입력되지 않았습니다.')
	end
	if clientCode.is_i? == false
		raise BarocertException.new('-99999999', '이용기관코드는 숫자만 입력할 수 있습니다.')
	end
	if clientCode.length != 12
		raise BarocertException.new('-99999999', '이용기관코드는 12자 입니다.')
	end
	if cms.nil?
		raise BarocertException.new('-99999999', '출금동의 요청정보가 입력되지 않았습니다.')
	end
	if cms["receiverHP"].to_s == ''
		raise BarocertException.new('-99999999', '수신자 휴대폰번호가 입력되지 않았습니다.')
	end
	if cms["receiverName"].to_s == ''
		raise BarocertException.new('-99999999', '수신자 성명이 입력되지 않았습니다.')
	end
	if cms["receiverBirthday"].to_s == ''
		raise BarocertException.new('-99999999', '생년월일이 입력되지 않았습니다.')
	end
	
	if cms["reqTitle"].to_s == ''
		raise BarocertException.new('-99999999', '인증요청 메시지 제목이 입력되지 않았습니다.')
	end

	if cms["expireIn"].to_s == ''
		raise BarocertException.new('-99999999', '만료시간이 입력되지 않았습니다.')
	end
	
	if cms["requestCorp"].to_s == ''
		raise BarocertException.new('-99999999', '청구기관명이 입력되지 않았습니다.')
	end

	if cms["bankName"].to_s == ''
		raise BarocertException.new('-99999999', '은행명이 입력되지 않았습니다.')
	end
	
	if cms["bankAccountNum"].to_s == ''
		raise BarocertException.new('-99999999', '계좌번호가 입력되지 않았습니다.')
	end
	
	if cms["bankAccountName"].to_s == ''
		raise BarocertException.new('-99999999', '예금주명이 입력되지 않았습니다.')
	end
	
	if cms["bankAccountBirthday"].to_s == ''
		raise BarocertException.new('-99999999', '예금주 생년월일이 입력되지 않았습니다.')
	end

	if cms["bankServiceType"].to_s == ''
		raise BarocertException.new('-99999999', '출금 유형이 입력되지 않았습니다.')
	end
	httppost("/KAKAO/CMS/#{clientCode}", cms.to_json)
end

#requestIdentity(clientCode, identity) ⇒ Object



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/barocert/kakaocert.rb', line 75

def requestIdentity(clientCode, identity)

	if clientCode.to_s == ''
		raise BarocertException.new('-99999999', '이용기관코드가 입력되지 않았습니다.')
	end
	if clientCode.is_i? == false
		raise BarocertException.new('-99999999', '이용기관코드는 숫자만 입력할 수 있습니다.')
	end
	if clientCode.length != 12
		raise BarocertException.new('-99999999', '이용기관코드는 12자 입니다.')
	end
	if identity.nil?
		raise BarocertException.new('-99999999', '본인인증 요청정보가 입력되지 않았습니다.')
	end
	if identity["receiverHP"].to_s == ''
		raise BarocertException.new('-99999999', '수신자 휴대폰번호가 입력되지 않았습니다.')
	end
	if identity["receiverName"].to_s == ''
		raise BarocertException.new('-99999999', '수신자 성명이 입력되지 않았습니다.')
	end
	if identity["receiverBirthday"].to_s == ''
		raise BarocertException.new('-99999999', '생년월일이 입력되지 않았습니다.')
	end
	
	if identity["reqTitle"].to_s == ''
		raise BarocertException.new('-99999999', '인증요청 메시지 제목이 입력되지 않았습니다.')
	end

	if identity["expireIn"].to_s == ''
		raise BarocertException.new('-99999999', '만료시간이 입력되지 않았습니다.')
	end
	
	if identity["token"].to_s == ''
		raise BarocertException.new('-99999999', '토큰 원문이 입력되지 않았습니다.')
	end

	httppost("/KAKAO/Identity/#{clientCode}", identity.to_json)
end

#requestMultiSign(clientCode, multiSign) ⇒ Object



248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
# File 'lib/barocert/kakaocert.rb', line 248

def requestMultiSign(clientCode, multiSign)
	if clientCode.to_s == ''
		raise BarocertException.new('-99999999', '이용기관코드가 입력되지 않았습니다.')
	end
	if clientCode.is_i? == false
		raise BarocertException.new('-99999999', '이용기관코드는 숫자만 입력할 수 있습니다.')
	end
	if clientCode.length != 12
		raise BarocertException.new('-99999999', '이용기관코드는 12자 입니다.')
	end
	if multiSign.nil?
		raise BarocertException.new('-99999999', '전자서명 요청정보가 입력되지 않았습니다.')
	end
	if multiSign["receiverHP"].to_s == ''
		raise BarocertException.new('-99999999', '수신자 휴대폰번호가 입력되지 않았습니다.')
	end
	if multiSign["receiverName"].to_s == ''
		raise BarocertException.new('-99999999', '수신자 성명이 입력되지 않았습니다.')
	end
	if multiSign["receiverBirthday"].to_s == ''
		raise BarocertException.new('-99999999', '생년월일이 입력되지 않았습니다.')
	end
	
	if multiSign["reqTitle"].to_s == ''
		raise BarocertException.new('-99999999', '인증요청 메시지 제목이 입력되지 않았습니다.')
	end

	if multiSign["expireIn"].to_s == ''
		raise BarocertException.new('-99999999', '만료시간이 입력되지 않았습니다.')
	end
	
	if isNullorEmptyTitle(multiSign["tokens"])
		raise BarocertException.new('-99999999', '서명 요청 제목이 입력되지 않았습니다.')
	end

	if isNullorEmptyToken(multiSign["tokens"])
		raise BarocertException.new('-99999999', '토큰 원문이 입력되지 않았습니다.')
	end

	if multiSign["tokenType"].to_s == ''
		raise BarocertException.new('-99999999', '원문 유형이 입력되지 않았습니다.')
	end

	httppost("/KAKAO/MultiSign/#{clientCode}", multiSign.to_json)
end

#requestSign(clientCode, sign) ⇒ Object



161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/barocert/kakaocert.rb', line 161

def requestSign(clientCode, sign)
	if clientCode.to_s == ''
		raise BarocertException.new('-99999999', '이용기관코드가 입력되지 않았습니다.')
	end
	if clientCode.is_i? == false
		raise BarocertException.new('-99999999', '이용기관코드는 숫자만 입력할 수 있습니다.')
	end
	if clientCode.length != 12
		raise BarocertException.new('-99999999', '이용기관코드는 12자 입니다.')
	end
	if sign.nil?
		raise BarocertException.new('-99999999', '전자서명 요청정보가 입력되지 않았습니다.')
	end
	if sign["receiverHP"].to_s == ''
		raise BarocertException.new('-99999999', '수신자 휴대폰번호가 입력되지 않았습니다.')
	end
	if sign["receiverName"].to_s == ''
		raise BarocertException.new('-99999999', '수신자 성명이 입력되지 않았습니다.')
	end
	if sign["receiverBirthday"].to_s == ''
		raise BarocertException.new('-99999999', '생년월일이 입력되지 않았습니다.')
	end
	
	if sign["signTitle"].to_s == '' && sign["reqTitle"].to_s == ''
		raise BarocertException.new('-99999999', '서명 요청 제목이 입력되지 않았습니다.')
	end

	if sign["expireIn"].to_s == ''
		raise BarocertException.new('-99999999', '만료시간이 입력되지 않았습니다.')
	end
	
	if sign["token"].to_s == ''
		raise BarocertException.new('-99999999', '토큰 원문이 입력되지 않았습니다.')
	end

	if sign["tokenType"].to_s == ''
		raise BarocertException.new('-99999999', '원문 유형이 입력되지 않았습니다.')
	end
	httppost("/KAKAO/Sign/#{clientCode}", sign.to_json)
end

#verifyCMS(clientCode, receiptID) ⇒ Object



421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
# File 'lib/barocert/kakaocert.rb', line 421

def verifyCMS(clientCode, receiptID)
	if clientCode.to_s == ''
		raise BarocertException.new('-99999999', '이용기관코드가 입력되지 않았습니다.')
	end
	if clientCode.is_i? == false
		raise BarocertException.new('-99999999', '이용기관코드는 숫자만 입력할 수 있습니다.')
	end
	if clientCode.length != 12
		raise BarocertException.new('-99999999', '이용기관코드는 12자 입니다.')
	end
	if receiptID.to_s == ''
		raise BarocertException.new('-99999999', '접수아이디가 입력되지 않았습니다.')
	end
	if receiptID.is_i? == false
		raise BarocertException.new('-99999999', '접수아이디는 숫자만 입력할 수 있습니다.')
	end
	if receiptID.length != 32
		raise BarocertException.new('-99999999', '접수아이디는 32자 입니다.')
	end

	httppost("/KAKAO/CMS/#{clientCode}/#{receiptID}")
end

#verifyIdentity(clientCode, receiptID) ⇒ Object



138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/barocert/kakaocert.rb', line 138

def verifyIdentity(clientCode, receiptID)
	if clientCode.to_s == ''
		raise BarocertException.new('-99999999', '이용기관코드가 입력되지 않았습니다.')
	end
	if clientCode.is_i? == false
		raise BarocertException.new('-99999999', '이용기관코드는 숫자만 입력할 수 있습니다.')
	end
	if clientCode.length != 12
		raise BarocertException.new('-99999999', '이용기관코드는 12자 입니다.')
	end
	if receiptID.to_s == ''
		raise BarocertException.new('-99999999', '접수아이디가 입력되지 않았습니다.')
	end
	if receiptID.is_i? == false
		raise BarocertException.new('-99999999', '접수아이디는 숫자만 입력할 수 있습니다.')
	end
	if receiptID.length != 32
		raise BarocertException.new('-99999999', '접수아이디는 32자 입니다.')
	end

	httppost("/KAKAO/Identity/#{clientCode}/#{receiptID}")
end

#verifyLogin(clientCode, txID) ⇒ Object



444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
# File 'lib/barocert/kakaocert.rb', line 444

def verifyLogin(clientCode, txID)
	if clientCode.to_s == ''
		raise BarocertException.new('-99999999', '이용기관코드가 입력되지 않았습니다.')
	end
	if clientCode.is_i? == false
		raise BarocertException.new('-99999999', '이용기관코드는 숫자만 입력할 수 있습니다.')
	end
	if clientCode.length != 12
		raise BarocertException.new('-99999999', '이용기관코드는 12자 입니다.')
	end
	if txID.to_s == ''
		raise BarocertException.new('-99999999', '트랜잭션 아이디가 입력되지 않았습니다.')
	end
	
	httppost("/KAKAO/Login/#{clientCode}/#{txID}")
end

#verifyMultiSign(clientCode, receiptID) ⇒ Object



317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
# File 'lib/barocert/kakaocert.rb', line 317

def verifyMultiSign(clientCode, receiptID)
	if clientCode.to_s == ''
		raise BarocertException.new('-99999999', '이용기관코드가 입력되지 않았습니다.')
	end
	if clientCode.is_i? == false
		raise BarocertException.new('-99999999', '이용기관코드는 숫자만 입력할 수 있습니다.')
	end
	if clientCode.length != 12
		raise BarocertException.new('-99999999', '이용기관코드는 12자 입니다.')
	end
	if receiptID.to_s == ''
		raise BarocertException.new('-99999999', '접수아이디가 입력되지 않았습니다.')
	end
	if receiptID.is_i? == false
		raise BarocertException.new('-99999999', '접수아이디는 숫자만 입력할 수 있습니다.')
	end
	if receiptID.length != 32
		raise BarocertException.new('-99999999', '접수아이디는 32자 입니다.')
	end

	httppost("/KAKAO/MultiSign/#{clientCode}/#{receiptID}")
end

#verifySign(clientCode, receiptID) ⇒ Object



225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
# File 'lib/barocert/kakaocert.rb', line 225

def verifySign(clientCode, receiptID)
	if clientCode.to_s == ''
		raise BarocertException.new('-99999999', '이용기관코드가 입력되지 않았습니다.')
	end
	if clientCode.is_i? == false
		raise BarocertException.new('-99999999', '이용기관코드는 숫자만 입력할 수 있습니다.')
	end
	if clientCode.length != 12
		raise BarocertException.new('-99999999', '이용기관코드는 12자 입니다.')
	end
	if receiptID.to_s == ''
		raise BarocertException.new('-99999999', '접수아이디가 입력되지 않았습니다.')
	end
	if receiptID.is_i? == false
		raise BarocertException.new('-99999999', '접수아이디는 숫자만 입력할 수 있습니다.')
	end
	if receiptID.length != 32
		raise BarocertException.new('-99999999', '접수아이디는 32자 입니다.')
	end

	httppost("/KAKAO/Sign/#{clientCode}/#{receiptID}")
end