Technical Documentations
  • 🇻🇳Vietnamese
    • Tổng quan
    • Đối tác B2B2C
      • Phương thức Webview
        • API Login
        • Yêu cầu bảo mật
        • Place Order
        • API Get Booking Detail
        • API Commit
        • API Check commit result
      • Phương thức SDK
        • API Login
        • Yêu cầu bảo mật
        • Initiate SDK
          • Init IOS SDK
          • Init Android SDK
        • Place order
        • API Commit
        • API Get booking detail
        • API Check commit result
      • Phương thức API
        • API Login
        • Yêu cầu bảo mật
        • ✈️Flight
          • Search API
          • Booking API
        • 🏨Hotel
          • Search API
          • Booking API
          • Cancellation API
        • Payment API
        • Booking Management API
    • Đối tác Corporate Agent (CA)
      • Qui trình tích hợp
      • API Chứng thực
      • Yêu cầu bảo mật
    • Đối tác Affiliate
    • ❓Câu hỏi thường gặp
      • Các status trong luồng booking Gotadi
      • Quy định Test
        • ✈️Vé máy bay
        • 🏨Khách sạn
      • Bộ Testcase dành cho đối tác B2B2C
      • Quy trình hỗ trợ từ CS
      • Danh sách Airlines
  • 🇬🇧English
    • Overview
    • B2B2C Partner
      • Webview method
        • API Login
        • Security Requirements
        • Place Order
        • API Get Booking Detail
        • API Commit
        • API Check commit result
      • SDK method
        • API Login
        • Security Requirments
        • Initiate SDK
          • Init IOS SDK
          • Init Android SDK
        • Place order
        • API Commit
        • API Get booking detail
        • API Check commit result
      • API method
        • Integration process
        • Login API
        • ✈️Flight
          • Search API
          • Booking API
        • 🏨Hotel
          • Search API
          • Booking API
          • Cancellation API
        • Payment API
    • Corporate Agent Partner (CA)
      • Integration Process
      • Authentication API
      • Security Requirements
    • Affiliate Partner
    • ❓FAQ section
      • Booking Statuses in Gotadi's Booking Flow
      • Regulations for Testing
        • ✈️Flight
        • 🏨Hotel
      • CS Support Overall Flow
      • Airlines List
Powered by GitBook
On this page
  • Kênh truyền SSL/HTTPS
  • Header bảo mật và thống kê lưu lượng truyền
  • Mã hóa dữ liệu truyền và xác thực chữ ký điện tử
  1. Vietnamese
  2. Đối tác B2B2C
  3. Phương thức Webview

Yêu cầu bảo mật

Kênh truyền SSL/HTTPS

SSL/HTTPS được áp dụng để truyền nhận dữ liệu giữa hệ thống của đối tác và Gotadi. Mục đích sử dụng SSL/HTTPS là giúp dữ liệu trao đổi giữa đối tác và Gotadi được mã hóa, khó bị đánh cắp và giả mạo.

Header bảo mật và thống kê lưu lượng truyền

Tất cả các request từ phía đối tác gọi sang hệ thống của Gotadi phải chứa các Headers bên dưới để phục vụ các nghiệp vụ về bảo mật và thống kê số liệu của Gotadi:

apikey: <api_key>
x-ibe-req-name: <access_code>

Lưu ý

Giá trị <api_key> và <access_code> do Gotadi cung cấp cho Đối tác.

Mã hóa dữ liệu truyền và xác thực chữ ký điện tử

Request/response giữa Gotadi và Đối tác ở một số API quan trọng được yêu cầu mã hóa bằng thuật toán mã hóa bất đối xứng 3DES và kèm theo chữ ký điện tử để xác thực. Thuật toán mã hóa, giải mã sẽ được mô tả cụ thể trong tài liệu này.

Lưu ý

Các API có yêu cầu mã hóa dữ liệu và kèm theo chữ ký điện tử sẽ được ghi chú ở phần Yêu cầu bảo mật.

Mã hóa dữ liệu gửi đi

  • Input Original data, RSA PublicKey của bên nhận, RSA Private Key của bên gửi

  • Output Encrypted Key, Encrypted Data

Bước 1: Khởi tạo khóa ngẫu nhiên (Random key)

Hàm 3DES Key Generate được dùng để tạo random key dựa theo tiêu chí DESedeKeySpec (Độ dài key: 24 byte). Mỗi request/response sẽ được cấp một random key riêng biệt.

Example:

    public static byte[] generateKey() throws Exception {
        KeyGenerator keyGenerator = KeyGenerator.getInstance("DESede");
        SecretKey secretKey = keyGenerator.generateKey();
        SecretKeyFactory secretKeyFactory = SecretKeyFactory.getInstance("DESede");
        DESedeKeySpec deSedeKeySpec = (DESedeKeySpec)   secretKeyFactory.getKeySpec(secretKey, DESedeKeySpec.class);
        byte[] randomKey = deSedeKeySpec.getKey();
        return randomKey;
    }
Bước 2: Mã hóa khóa ngẫu nhiên (Encrypted random key)

Random key được tạo ra ở bước 1 sẽ được mã hóa bằng thuật toán mã hóa bất đối xứng RSA bằng Public key của bên nhận.

Example:

public static String encryptRSA(byte[] randomKey, String xmlPublicKey) throws Exception {
    Cipher cipher = createCipherEncrypt(xmlPublicKey);
    byte[] encryptedKey = cipher.doFinal(randomKey);
    return Base64.encodeBase64URLSafeString(encryptedKey);
}
Bước 3: Khởi tạo chữ ký chữ ký điện tử (Signature)

Bên gửi áp dụng thuật toán RSA-SHA256 kết hợp với Private key của chính mình để ký chữ ký điện tử trên signature data.

Lưu ý

Schema để thành lập signature data sẽ được mô tả cụ thể ở từng API.

Example:

public static String signRSA(String signatureData, String xmlPrivateKey) throws Exception {
    PrivateKey privateKey = getPrivateKeyFromXML(xmlPrivateKey);
    Signature instance = Signature.getInstance("SHA256withRSA");
    instance.initSign(privateKey);
    instance.update(signatureData.getBytes("UTF-8"));
    byte[] signature = instance.sign();
    return Base64.encodeBase64String(signature);
}
Bước 4: Mã hóa dữ liệu (Encrypted data)

Original data có chứa signature sẽ được mã hóa bằng thuật toán 3DES với random key đã được tạo ra ở bước trước đó.

Lưu ý

Schema để thành lập original data sẽ được mô tả cụ thể ở từng API.

Example:

public static String encryptTripleDes(String originalData, byte[] randomKey) throws Exception {
    Cipher cipher = Cipher.getInstance("DESede");
    SecretKeySpec secretKeySpec = new SecretKeySpec(randomKey, "DESede");
    cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec);
    byte[] encryptedData = cipher.doFinal(originalData.getBytes("UTF-8"));
    return Base64.encodeBase64URLSafeString(encryptedData);
}

Giải mã dữ liệu nhận được và xác thực chữ ký điện tử

  • Input Encrypted Key, Encrypted Data, RSA PrivateKey của bên nhận, RSA PublicKey của bên gửi

  • Output Original Data, Verify Result

Bước 1: Giải mã khóa ngẫu nhiên 3DES (Decrypted random key)

Bên nhận sử dụng Private key của chính mình để giải mã encrypted key nhận được.

Example:

public static byte[] decryptRSAToByte(String encryptedKey, String xmlPrivateKey) throws Exception {
    Cipher cipher = createCipherDecrypt(xmlPrivateKey);
    byte[] bts = Base64.decodeBase64(encryptedKey);
    byte[] randomKey = cipher.doFinal(bts);
    return randomKey;
}
Bước 2: Giải mã dữ liệu (Decrypted data)

Bên nhận áp dụng thuật toán 3DES kết hợp với random key có được ở bước trước đó, giải mã encrypted data để nhận được original data có chứa signature.

Lưu ý

Schema để thành lập original data sẽ được mô tả cụ thể ở từng API.

Example:

public static String decryptTripleDes(String encryptedData, byte[] randomKey) throws Exception {
    Cipher cipher = Cipher.getInstance("DESede");
    SecretKeySpec secretKeySpec = new SecretKeySpec(randomKey, "DESede");
    cipher.init(Cipher.DECRYPT_MODE, secretKeySpec);
    byte[] originalData  = cipher.doFinal(Base64.decodeBase64(encryptedData));
    return new String(originalData, "UTF-8");
}
Bước 3: Xác thực chữ ký điện tử

Bên nhận sử dụng Thuật toán RSA-SHA256 và Public key của bên gửi để xác thực signature được lấy ra từ original data.

Example:

public static boolean verifyRSA(String signedData, String signature, String xmlPublicKey) throws Exception {
    PublicKey publicKey = getPublicKeyFromXML(xmlPublicKey);
    Signature instance = Signature.getInstance("SHA256withRSA");
    instance.initVerify(publicKey);
    instance.update(signedData.getBytes("UTF-8"));
    return instance.verify(Base64.decodeBase64(signature));
}

PreviousAPI LoginNextPlace Order

Last updated 2 months ago

🇻🇳