UpdatePersonalICode

Updated at:

Updates the personal identification number of a user.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

No authorization for this operation. If you encounter issues with this operation, contact technical support.

Request syntax

POST  HTTP/1.1

Request parameters

Parameter

Type

Required

Description

Example

QuickBIUserId

string

No

The user ID in Quick BI.

sasdasasd

Response elements

Element

Type

Description

Example

object

RequestId

string

The request ID.

685072a0-1fd5-40ef-ae6b-cf94e79e718f

Result

object

The AK model.

{ "icode": "V2Yc/dMFWBwTKLNCNxgnN****z***5ARu", "icodeKey": "b6f3***32a62936", "type": 1 }

Type

integer

The AK type. Currently, only the value 1 is supported, which indicates a personal AK.

1

Icode

string

SK

V2Yc/dMFWBwTKLNCNxgnN****z***5ARu

IcodeKey

string

AK

b6f3***32a62936

Success

boolean

Indicates whether the request is successful. Valid values:

  • true: The request is successful.

  • false: The request fails.

true

The SK data must be decrypted before use. If you have not configured an organization key, contact Quick BI support to configure the organization key. You must provide your Base64-encoded key.

Important The ciphertext returned by Quick BI uses AES symmetric encryption. The specific parameters are as follows. Decrypt the data accordingly: Algorithm/Mode/Padding: AES/ECB/PKCS5Padding. Key length: AES-128 (16 bytes). Ciphertext processing: The icode ciphertext string returned by the API is Base64-encoded. Decode the Base64 string to obtain the ciphertext bytes, and then perform AES decryption. Character set: Convert the decrypted plaintext bytes to a string using UTF-8. The ECB mode does not require an IV (initialization vector). Decryption steps: Base64-decode your key -> Base64-decode the icode ciphertext -> Decrypt using AES/ECB/PKCS5Padding -> Convert to a string using UTF-8.

Sample Java decryption code:

package com.example.demo.openapi;

import javax.crypto.BadPaddingException;

import javax.crypto.Cipher;

import javax.crypto.IllegalBlockSizeException;

import javax.crypto.NoSuchPaddingException;

import javax.crypto.spec.SecretKeySpec;

import java.nio.charset.StandardCharsets;

import java.security.GeneralSecurityException;

import java.security.InvalidKeyException;

import java.security.NoSuchAlgorithmException;

import java.util.Base64;

public class testddd {

public static final String KEY_ALGORITHM = "AES";

public static final String CIPHER_ALGORITHM = "AES/ECB/PKCS5Padding";
/**
 * Your Base64-encoded key.
 */
public static final String BASE_64 = "xxxx";

public static void main(String[] args) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException {
    String decrypt = decrypt("iCode-api-return", BASE_64);
    System.out.println(decrypt);
}

/**
 * Decrypts the {@code icode} returned by the API to restore the plaintext SK.
 *
 * @param cipherIcode   The {@code icode} field returned by the API, which is the Base64-encoded AES ciphertext.
 * @param base64SecretKey The key provided by your company to Quick BI, which is a Base64-encoded 16-, 24-, or 32-byte key.
 * @return The plaintext SK.
 * @throws IcodeDecryptException Thrown when the ciphertext or key is invalid, or the key does not match. The exception message contains troubleshooting suggestions.
 */
public static String decrypt(String cipherIcode, String base64SecretKey)  {
    byte[] keyBytes;
    try {
        keyBytes = Base64.getDecoder().decode(normalize(base64SecretKey));
    } catch (IllegalArgumentException e) {
        throw new IcodeDecryptException("The key is not a valid Base64 string. Make sure that you use the Base64-encoded key "
                + "instead of the original password text.", e);
    }

    byte[] cipherBytes;
    try {
        cipherBytes = Base64.getDecoder().decode(normalize(cipherIcode));
    } catch (IllegalArgumentException e) {
        throw new IcodeDecryptException("The icode is not a valid Base64 string. Make sure that you pass the original icode field returned by the API.", e);
    }

    try {
        Cipher cipher = Cipher.getInstance(CIPHER_ALGORITHM);
        cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(keyBytes, KEY_ALGORITHM));
        // The SK consists of visible ASCII characters. Restoring it using UTF-8 is consistent with the character set used for server-side encryption.
        return new String(cipher.doFinal(cipherBytes), StandardCharsets.UTF_8);
    } catch (GeneralSecurityException e) {
        throw new IcodeDecryptException("Decryption failed. Check whether the key is the same as the one used for encryption, or whether the ciphertext is truncated or tampered with.", e);
    }
}

/**
 * Base64 normalization: removes all whitespace characters (some gateways or logs may insert line breaks in long strings),
 * and restores the URL-safe variants {@code -} and {@code _} to the standard Base64 characters {@code +} and {@code /}
 * (the {@code +} character is often decoded as a space during form transmission, which is also restored here).
 */
private static String normalize(String base64Text) {
    if (base64Text == null) {
        throw new IllegalArgumentException("The Base64 content cannot be empty.");
    }
    StringBuilder sb = new StringBuilder(base64Text.length());
    for (int i = 0; i < base64Text.length(); i++) {
        char c = base64Text.charAt(i);
        if (c == ' ' || c == '\t' || c == '\r' || c == '\n' || c == '\f') {
            // Skip whitespace. Note that spaces in the ciphertext can only come from '+' being decoded by forms, which is handled by the following branch.
            continue;
        }
        if (c == '-') {
            sb.append('+');
        } else if (c == '_') {
            sb.append('/');
        } else {
            sb.append(c);
        }
    }
    return sb.toString();
}

/**
 * The exception that occurs during icode decryption.
 */
public static class IcodeDecryptException extends RuntimeException {
    public IcodeDecryptException(String message) {
        super(message);
    }

    public IcodeDecryptException(String message, Throwable cause) {
        super(message, cause);
    }
}

}

Examples

Success response

JSON format

{
  "RequestId": "685072a0-1fd5-40ef-ae6b-cf94e79e718f",
  "Result": {
    "Type": 1,
    "Icode": "V2Yc/dMFWBwTKLNCNxgnN****z***5ARu",
    "IcodeKey": "b6f3***32a62936"
  },
  "Success": true
}

Error codes

HTTP status code

Error code

Error message

Description

400 Internal.System.Error An internal system error occurred. An internal system error occurred.
400 Invalid.Parameter.Error The parameter is invalid:%s. invalid parameter: ${0}.
400 Invalid.User.Organization The user is not in your organization. The user is not in your organization.
400 UserInfo.Error The personal information is invalid. The personal information is invalid.
400 PersonalIcode.NotExist.Error Personal identification code not exist, please create it first: %s. Personal identification code does not exist, please create it first: %s.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.