{"info":{"_postman_id":"3e8c6f1e-8c0c-4f0c-86a5-70daef25fca0","name":"PSU-DS","description":"<html><head></head><body><h3 id=\"diis-core-services-psu-ds\">DIIS Core Services: PSU-DS</h3>\n<p>เพื่อใช้สำหรับการสร้าง Digital Signature</p>\n<p>การสร้าง Digital Signature ด้วย API นี้ ทาง client จะใช้เทคนิคที่เรียกว่า <b>external sign</b> โดยคำนวนหา hash ของ pdf content ที่ต้องการ Sign (รวม Signature Apperance) แล้วทำการส่งค่า hash มายัง server เพื่อรับ Sign Data ไปใส่ใน pdf</p>\n<h6 id=\"java-และ-c\">Java และ C#</h6>\n<p>แนะนำให้ใช้ iText<br><a href=\"https://kb.itextpdf.com/home/it7kb/examples/digital-signatures-chapter-4\">https://kb.itextpdf.com/home/it7kb/examples/digital-signatures-chapter-4</a></p>\n<p><a href=\"https://gist.github.com/suthon-psu/209d4164999bafd2c6101af3c7042dd0\">https://gist.github.com/suthon-psu/209d4164999bafd2c6101af3c7042dd0</a></p>\n<p>StartFragmentdFragment</p>\n<h6 id=\"php\">PHP</h6>\n<p>แนะนำให้ใช้ SetaPDF-Signer</p>\n<p><a href=\"https://manuals.setasign.com/setapdf-signer-manual/signature-modules/individual-module\">https://manuals.setasign.com/setapdf-signer-manual/signature-modules/individual-module</a></p>\n<h6 id=\"python\">Python</h6>\n<p><a href=\"https://pypi.org/project/psusigner/\">https://pypi.org/project/psusigner/</a> (ขอบคุณไลบราลีจาก อ.ธนาธิป)</p>\n<p>(source code: <a href=\"https://gitlab.psu.ac.th/diis-itoc/psu-signer?fbclid=IwAR1rsZ1XULBzG5gR1sGwGITgylJWwLfbiPFUkjxPeXlKbSo2qpHgaTvwXIg\">https://gitlab.psu.ac.th/diis-itoc/psu-signer</a>)</p>\n</body></html>","schema":"https://schema.getpostman.com/json/collection/v2.0.0/collection.json","toc":[],"owner":"644041","collectionId":"3e8c6f1e-8c0c-4f0c-86a5-70daef25fca0","publishedId":"2s93eU1tyD","public":true,"customColor":{"top-bar":"FFFFFF","right-sidebar":"303030","highlight":"FF6C37"},"publishDate":"2023-05-01T17:04:02.000Z"},"item":[{"name":"Sign","id":"08c1cd1d-007c-4fe0-87b5-b570e53f176c","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[{"key":"X-Agent-Key","value":"H2MMK2jjwRzVz3ta1","description":"<p>สำหรับแจ้งให้ทราบว่าเป็น Agent ใด</p>\n","type":"text"}],"body":{"mode":"raw","raw":"{\r\n    \"code\": \"c1\",\r\n    \"secret\": \"87654321\",\r\n    \"pdfHash\": \"ZX69KEPmcdlmZNbW0/t9+aEU5PEXtQs7/1r+PWLvM8Y=\",\r\n    \"ref1\": \"ref1\",\r\n    \"ref2\": \"ref2\",\r\n    \"remark\": \"remark..\"\r\n}","options":{"raw":{"language":"json"}}},"url":"https://ds-dev.psu.ac.th/api/v1/sign/withPdfSignature","description":"<p>JSON Body</p>\n<ul>\n<li>code: โค้ดของ Certificate ที่ต้องการใช้</li>\n<li>secret: สำหรับถอดรหัส Certificate (จะแตกต่างกันใน Agent และ Code)</li>\n<li>pdfHash: hash ของ pdf ที่ต้องการ sign</li>\n</ul>\n","urlObject":{"path":["api","v1","sign","withPdfSignature"],"host":["https://ds-dev.psu.ac.th"],"query":[],"variable":[]}},"response":[{"id":"cbd0b86e-efe8-470e-895b-fcc5e80ed266","name":"Sign","originalRequest":{"method":"POST","header":[{"key":"X-Agent-Key","value":"H2MMK2jjwRzVz3ta1","type":"text"}],"body":{"mode":"raw","raw":"{\r\n    \"code\": \"c1\",\r\n    \"secret\": \"87654321\",\r\n    \"pdfHash\": \"ZX69KEPmcdlmZNbW0/t9+aEU5PEXtQs7/1r+PWLvM8Y=\"\r\n}","options":{"raw":{"language":"json"}}},"url":"https://ds-dev.psu.ac.th/api/v1/sign/withPdfSignature"},"status":"OK","code":200,"_postman_previewlanguage":"json","header":[{"key":"Server","value":"nginx/1.18.0 (Ubuntu)"},{"key":"Date","value":"Mon, 01 May 2023 16:26:58 GMT"},{"key":"Content-Type","value":"application/json;charset=UTF-8"},{"key":"Transfer-Encoding","value":"chunked"},{"key":"Connection","value":"keep-alive"},{"key":"Vary","value":"Origin"},{"key":"Vary","value":"Access-Control-Request-Method"},{"key":"Vary","value":"Access-Control-Request-Headers"}],"cookie":[],"responseTime":null,"body":"{\n    \"statusCode\": 1,\n    \"signData\": \"...\"\n}"}],"_postman_id":"08c1cd1d-007c-4fe0-87b5-b570e53f176c"},{"name":"Sign (Signed Request)","id":"31edd5fb-b3e2-445d-8061-5bd5934d68f0","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[{"key":"X-Agent-Key","value":"H2MMK2jjwRzVz3ta2","type":"text"}],"body":{"mode":"raw","raw":"{\r\n    \"payload\": \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb2RlIjoiYzEiLCJzZWNyZXQiOiIxMjM0NTY3OCIsInBkZkhhc2giOiJaWDY5S0VQbWNkbG1aTmJXMC90OSthRVU1UEVYdFFzNy8xcitQV0x2TThZPSJ9.F4OWK2g2Pp2IFfLx3Clpq6A7uGRdtqmd2NEmXzLxOk0\"\r\n}","options":{"raw":{"language":"json"}}},"url":"https://ds-dev.psu.ac.th/api/v1/sign/withPdfSignature","description":"<p>jwtSecret ที่ใช้ใน API ทดสอบคือ 6MDhMa7LT+5Rb7RnnOaMWbVVG0xhZLXZAEJQpDBEnX5ndLjY8kKusEC5LFAXU/9QzKtbUcT6AGaNW2I8jnMACg==</p>\n<p>ทั้งนี้ jwtSecret จะเป็นค่า per Agent</p>\n<p>เราทำขั้นตอนนี้เพื่อแสดง proof of identity โดยที่ jwtSecret จะไม่ถูกส่งไปพร้อมกับ request (ต่างกับ Agent Key)</p>\n<p>สามารถทดลองออก jwt token ได้จาก <a href=\"https://jwt.io/\">https://jwt.io/</a></p>\n<p>JSON Body</p>\n<ul>\n<li>payload: JWT ที่ถูก sign ด้วย jwtSecret</li>\n</ul>\n<p>ทั้งนี้ในตย. payload จะเป็นการ encode ข้อมูล string ดังแสดงข้างล่างด้วย alg = HS256<br />{<br />\"code\": \"c1\",<br />\"secret\": \"12345678\",<br />\"pdfHash\": \"ZX69KEPmcdlmZNbW0/t9+aEU5PEXtQs7/1r+PWLvM8Y=\"<br />}</p>\n","urlObject":{"path":["api","v1","sign","withPdfSignature"],"host":["https://ds-dev.psu.ac.th"],"query":[],"variable":[]}},"response":[],"_postman_id":"31edd5fb-b3e2-445d-8061-5bd5934d68f0"},{"name":"Logs","id":"5431b2ea-bc35-4964-9a0e-94c5af4e9e34","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[{"key":"X-Agent-Key","value":"H2MMK2jjwRzVz3ta1","type":"text"}],"url":"https://ds-dev.psu.ac.th/api/v1/sign/logs?ref1=ref1&ref2=ref2&max=10&offset=0&sort=actionDateTime&order=desc","urlObject":{"path":["api","v1","sign","logs"],"host":["https://ds-dev.psu.ac.th"],"query":[{"disabled":true,"key":"certEntryCode","value":"c1"},{"description":{"content":"<p>exact match</p>\n","type":"text/plain"},"key":"ref1","value":"ref1"},{"description":{"content":"<p>partial match</p>\n","type":"text/plain"},"key":"ref2","value":"ref2"},{"disabled":true,"description":{"content":"<p>must apply when filter by action datetime</p>\n","type":"text/plain"},"key":"fromActionDateTime","value":"2023-06-05T11:00:00"},{"disabled":true,"description":{"content":"<p>optional when filter by action datetime</p>\n","type":"text/plain"},"key":"toActionDateTime","value":"2023-06-05T12:00:00"},{"description":{"content":"<p>maximum result</p>\n","type":"text/plain"},"key":"max","value":"10"},{"description":{"content":"<p>result offset for pagination</p>\n","type":"text/plain"},"key":"offset","value":"0"},{"description":{"content":"<p>[id, ref1, ref2, actionDateTime]</p>\n","type":"text/plain"},"key":"sort","value":"actionDateTime"},{"description":{"content":"<p>[asc, desc]</p>\n","type":"text/plain"},"key":"order","value":"desc"}],"variable":[]}},"response":[{"id":"2ec6d8af-4caf-4bfb-8672-4a62b7cae6d1","name":"Logs","originalRequest":{"method":"GET","header":[{"key":"X-Agent-Key","value":"H2MMK2jjwRzVz3ta1","type":"text"}],"url":{"raw":"https://ds-dev.psu.ac.th/api/v1/sign/logs?ref1=ref1&ref2=ref2&fromActionDateTime=2023-06-05T11:00:00&toActionDateTime=2023-06-05T12:00:00&max=10&offset=0&sort=actionDateTime&order=desc","host":["https://ds-dev.psu.ac.th"],"path":["api","v1","sign","logs"],"query":[{"key":"certEntryCode","value":"c1","disabled":true},{"key":"ref1","value":"ref1","description":"exact match"},{"key":"ref2","value":"ref2","description":"partial match"},{"key":"fromActionDateTime","value":"2023-06-05T11:00:00","description":"must apply when filter by action datetime"},{"key":"toActionDateTime","value":"2023-06-05T12:00:00","description":"optional when filter by action datetime"},{"key":"max","value":"10"},{"key":"offset","value":"0"},{"key":"sort","value":"actionDateTime","description":"[id, ref1, ref2, actionDateTime]"},{"key":"order","value":"desc","description":"[asc, desc]"}]}},"status":"OK","code":200,"_postman_previewlanguage":"json","header":[{"key":"Vary","value":"Origin"},{"key":"Vary","value":"Access-Control-Request-Method"},{"key":"Vary","value":"Access-Control-Request-Headers"},{"key":"Content-Type","value":"application/json;charset=UTF-8"},{"key":"Content-Language","value":"en-US"},{"key":"Transfer-Encoding","value":"chunked"},{"key":"Date","value":"Mon, 05 Jun 2023 04:43:34 GMT"},{"key":"Keep-Alive","value":"timeout=60"},{"key":"Connection","value":"keep-alive"}],"cookie":[],"responseTime":null,"body":"{\n    \"statusCode\": 1,\n    \"data\": [\n        {\n            \"id\": \"2c9370818889cf13018889dc64b10005\",\n            \"certEntryCode\": \"c1\",\n            \"signatureHash\": \"ZX69KEPmcdlmZNbW0/t9+aEU5PEXtQs7/1r+PWLvM8Y=\",\n            \"remark\": \"remark..\",\n            \"ref2\": \"ref2\",\n            \"ref1\": \"ref1\",\n            \"actionDateTime\": \"2023-06-05T11:41:42.312\"\n        }\n    ],\n    \"totalCount\": 1\n}"}],"_postman_id":"5431b2ea-bc35-4964-9a0e-94c5af4e9e34"}],"event":[{"listen":"prerequest","script":{"id":"ce479c26-c80b-4d0e-8174-b938dc3d0574","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"cd02ff25-86e8-49ab-b77a-50cb50c5c8dd","type":"text/javascript","exec":[""]}}],"variable":[{"key":"apiUrlPrefix","value":"https://ds-dev.psu.ac.th","type":"string"}]}