批量更新用户密码接口

  • 接口:common/users/v2/updatePasswordBatch
  • Method:PUT
  • 数据格式:JSON
  • 限流信息:150次每天和50次每小时
  • 多语言环境:更新密码业务不需要区分多语言
  • 接口说明:该接口用于批量更新用户账户的密码,在整批数据中处理中可能出现部分输入的用户名不存在,输入的密码格式不正确等原因导致更新不成功,其他正常数据会被处理。接口拥有异步处理逻辑,当批量数据大于200时,将自动转为异步处理。异步处理的结果请使用 common/sync/${请求的bizId} 获取
  • 其他补充信息:该接口传入的密码为加密形式。约定的加密方式是 AES。加解密使用的密钥使用 运维平台/接口管理/授权配置页面的 client_secret 值, 如果没有,请点击初始化一个,一旦初始化则不能更改。
  • 约定的加密方法如下:
// 如果你的服务可以引用 cloudpense 的基础包。 则可以直接引用alice 包的AESUtils的对应方法
// type = 1 时,加密。 type = 2 时, 解密。
public class AesUtil{
    public static String aes(String content, String password, int type){
        if(content==null){
            return null;
        } else {
            try {
                KeyGenerator generator=KeyGenerator.getInstance("AES");
                SecureRandom random= SecureRandom.getInstance("SHA1PRNG");
                random.setSeed(password.getBytes());
                generator.init(256,random);
                SecretKey secretKey=generator.generateKey();
                byte[]enCodeFormat=secretKey.getEncoded();
                SecretKeySpec key=new SecretKeySpec(enCodeFormat,"AES");
                Cipher cipher=Cipher.getInstance("AES");
                cipher.init(type,key);
                byte[]byteContent;
                if(type==1) {
                    byteContent=content.getBytes(StandardCharsets.UTF_8);
                    return byte2HexStr(cipher.doFinal(byteContent));
                }else {
                    byteContent = hexStr2Byte(content);
                    return new String(cipher.doFinal(byteContent));
                }
            }catch(Exception var10) {
                var10.printStackTrace();
                return null;
            }
        }
    }

    private static String byte2HexStr(byte[] bytes) {
        StringBuilder sb = new StringBuilder();
        byte[] var2 = bytes;
        int var3 = bytes.length;

        for(int var4 = 0; var4 < var3; ++var4) {
            byte b = var2[var4];
            String hex = Integer.toHexString(b & 255);
            if (hex.length() == 1) {
                hex = '0' + hex;
            }

            sb.append(hex.toUpperCase());
        }

        return sb.toString();
    }

    private static byte[] hexStr2Byte(String hexStr) {
        if (hexStr.length() < 1) {
            return null;
        } else {
            byte[] result = new byte[hexStr.length() / 2];

            for(int i = 0; i < hexStr.length() / 2; ++i) {
                int high = Integer.parseInt(hexStr.substring(i * 2, i * 2 + 1), 16);
                int low = Integer.parseInt(hexStr.substring(i * 2 + 1, i * 2 + 2), 16);
                result[i] = (byte)(high * 16 + low);
            }

            return result;
        }
    }
}

参数:

请求参数

字段名称 字段类型 字段描述 是否必填 长度限制(字节)
bizId String 当前次接口同步的唯一标识 TRUE 36
timestamp long 当前次接口同步对应的时间戳 TRUE 13
data Array 当前次接口同步的数据集合 TRUE
data.code String 用户员工号 TRUE 64
data.user_name String 用户名(注意是fnd_user 的 user_name, 而不是 full_name) TRUE 255
data.password String 密码(加密的) TRUE 255
data.password_reset_required String 密码是否需要重置(Y/N) FALSE 1

返回参数

字段名称 字段类型 字段描述
bizId String 当前次接口同步的唯一标识
resCode Integer 响应状态码(见附录)
resMsg String 返回信息描述
data JSON 更新结果详情
data.count Integer 成功更新的条数
data.password_validator_errors Array 密码格式校验失败对应的用户名记录
data.name_validator_errors Array 用户名验证不存在的记录

示例:

请求数据

{
    "bizId":"d212175f-5bdf-43r8-a235-a014dc119ffd",
    "timestamp":1700722461000,
    "data":[
        {
        "code":"codexxxx", 
        "user_name":"wh1@wh1",
        "password":"FB4EC7BD2A4E2AD961A856Bv408793008",
          "password_reset_required":"Y"
        },   
        {
        "code":"codexxxx", 
          "user_name":"wh2@wh2",
        "password":"7827F8AE5A4CB61EC6D4v1DEA2A63E3AC"
        },
        {
        "code":"codexxxx", 
          "user_name":"wh3@wh3",
        "password":"7827F8AE5A4CB61EC6D41DEA2A63E3AC",
          "password_reset_required":"Y"
        },    
        {
        "code":"codexxxx", 
          "user_name":"wh4@wh4",
        "password":"7827F8AE5A4CB61EC6D41DEA2A63E3AC"
        }
        ]
    }

返回数据


{
    "resCode": 200000,
    "resMsg": "SUCCESS",
    "bizId": "d212175f-5bdf-43r8-a235-a014dc119ffd",
    "data": {
        "password_validator_errors": [
            "wh1@wh1",
            "wh2@wh2"
        ],
        "name_validator_errors": [
            "wh4@wh4"
        ],
        "count": 1
    }
}

results matching ""

    No results matching ""