cn.hutool.core.lang.UUID Java Examples

The following examples show how to use cn.hutool.core.lang.UUID. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AudioUtil.java    From zfile with MIT License 6 votes vote down vote up
public static AudioInfoDTO getAudioInfo(String url) throws Exception {
    String query = new URL(URLUtil.decode(url)).getQuery();

    if (query != null) {
        url = url.replace(query, URLUtil.encode(query));
    }

    // 如果音乐文件大小超出 5M, 则不解析此音乐
    if (im.zhaojun.zfile.util.HttpUtil.getRemoteFileSize(url)
            > (1024 * 1024 * ZFileConstant.AUDIO_MAX_FILE_SIZE_MB)) {
        return AudioInfoDTO.buildDefaultAudioInfoDTO();
    }

    String fullFilePath = StringUtils.removeDuplicateSeparator(ZFileConstant.TMP_FILE_PATH + ZFileConstant.PATH_SEPARATOR + UUID.fastUUID());

    File file = new File(fullFilePath);
    FileUtil.mkParentDirs(file);
    HttpUtil.downloadFile(url, file);
    AudioInfoDTO audioInfoDTO = parseAudioInfo(file);
    audioInfoDTO.setSrc(url);
    file.deleteOnExit();
    return audioInfoDTO;
}
 
Example #2
Source File: AppleController.java    From signature with MIT License 6 votes vote down vote up
@ApiOperation(value = "/uploadP12", notes = "上传p12文件", produces = "application/json")
@ApiImplicitParams(value = {
        @ApiImplicitParam(name = "id", value = "开发者账号id", required = true),
        @ApiImplicitParam(name = "file", value = "p12文件", required = true)
})
@PostMapping("/uploadP12")
public Result uploadP12(long id, MultipartFile file) throws IOException {
    Result result = new Result();
    String p12 = UUID.randomUUID().toString().replace("-", "") + ".p12";
    if (file.getContentType().equalsIgnoreCase("application/x-pkcs12")) {
        // p12文件
        uploadP12File(file.getBytes(), p12);
        int i = appleService.updateAppleAccountWithP12(p12, id);
        if (i==1) {
            result.setCode(1);
            result.setMsg("信息更新成功");
        }else {
            result.setMsg("信息更新失败");
        }
    }else {
        result.setMsg("文件类型错误,请上传p12文件");
    }
    return result;
}
 
Example #3
Source File: OcrUtils.java    From tools-ocr with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static String ocrImg(byte[] imgData) {
    int i = Math.abs(UUID.randomUUID().hashCode()) % 4;
    StaticLog.info("OCR Engine: " + i);
    switch (i){
        case 0:
            return bdGeneralOcr(imgData);
        case 1:
            return bdAccurateOcr(imgData);
        case 2:
            return sogouMobileOcr(imgData);
        default:
            return sogouWebOcr(imgData);
    }
}
 
Example #4
Source File: UDIDController.java    From signature with MIT License 5 votes vote down vote up
/**
 * create by: iizvv
 * description: 上传IPA
 * create time: 2019-07-05 13:11

 * @return void
 */
String uploadIPA(File file) {
    String objName = UUID.randomUUID().toString().replace("-", "")+".ipa";
    System.out.println("开始上传最终ipa文件, 文件名: " + objName);
    fileManager.uploadFile(file, objName);
    System.out.println("文件上传完成");
    file.delete();
    System.out.println("ipa文件删除: " + objName);
    return objName;
}
 
Example #5
Source File: ITSUtils.java    From signature with MIT License 4 votes vote down vote up
/**
 * create by: iizvv
 * description: 创建个人资料
 * create time: 2019-06-29 15:33
 *

 * @return File
 */
public static File insertProfile(Apple apple, String devId, String path) {
    Map body = new HashMap();
    body.put("type", "profiles");
    String name = UUID.randomUUID().toString().replace("-", "");
    Map attributes = new HashMap();
    attributes.put("name", name);
    attributes.put("profileType", "IOS_APP_DEVELOPMENT");
    body.put("attributes", attributes);
    Map relationships = new HashMap();
    Map bundleId = new HashMap();
    Map data2 = new HashMap();
    data2.put("id", apple.getBundleIds());
    data2.put("type", "bundleIds");
    bundleId.put("data", data2);
    relationships.put("bundleId", bundleId);
    Map certificates = new HashMap();
    Map data3 = new HashMap();
    data3.put("id", apple.getCerId());
    data3.put("type", "certificates");
    List list = new LinkedList();
    list.add(data3);
    certificates.put("data", list);
    relationships.put("certificates", certificates);
    Map devices = new HashMap();
    Map data4 = new HashMap();
    data4.put("id", devId);
    data4.put("type", "devices");
    List list2 = new LinkedList();
    list2.add(data4);
    devices.put("data", list2);
    relationships.put("devices", devices);
    body.put("relationships", relationships);
    Map data = new HashMap();
    data.put("data", body);
    String url = "https://api.appstoreconnect.apple.com/v1/profiles";
    String result = HttpRequest.post(url).
            addHeaders(getToken(apple.getP8(), apple.getIss(), apple.getKid())).
            body(JSON.toJSONString(data)).execute().body();
    Map map = JSON.parseObject(result, Map.class);
    Map o = (Map) map.get("data");
    Map o2 = (Map) o.get("attributes");
    String profileContent = (String) o2.get("profileContent");
    File file = base64ToFile(profileContent, path + name + ".mobileprovision");
    return file;
}
 
Example #6
Source File: UDIDController.java    From signature with MIT License 4 votes vote down vote up
/**
  * create by: iizvv
  * description: 下载IPA的item-service
  * create time: 2019-07-06 10:34

  * @return
  */
String software(String ipaUrl, String id, String version, String title) {
    ipaUrl = Config.aliTempHost + "/" + ipaUrl;
    System.out.println("ipaUrl: " + ipaUrl);
    String plist = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>  \n" +
            "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">  \n" +
            "<plist version=\"1.0\">  \n" +
            "<dict>  \n" +
            "    <key>items</key>  \n" +
            "    <array>  \n" +
            "        <dict>  \n" +
            "            <key>assets</key>  \n" +
            "            <array>  \n" +
            "                <dict>  \n" +
            "                    <key>kind</key>  \n" +
            "                    <string>software-package</string>  \n" +
            "                    <key>url</key>  \n" +
            "                    <string>"+ ipaUrl +"</string>  \n" +
            "                </dict>  \n" +
            "            </array>  \n" +
            "            <key>metadata</key>  \n" +
            "            <dict>  \n" +
            "                <key>bundle-identifier</key>  \n" +
            "                <string>"+ id +"</string>  \n" +
            "                <key>bundle-version</key>  \n" +
            "                <string>" + version + "</string>  \n" +
            "                <key>kind</key>  \n" +
            "                <string>software</string>  \n" +
            "                <key>title</key>  \n" +
            "                <string>" + title + "</string>  \n" +
            "            </dict>  \n" +
            "        </dict>  \n" +
            "    </array>  \n" +
            "</dict>  \n" +
            "</plist> ";
    String filePath = "itemService_" + UUID.randomUUID().toString().replace("-", "") +".plist";
    FileWriter writer = new FileWriter(filePath);
    writer.write(plist);
    String itemService = uploadItemService(writer.getFile());
    writer.getFile().delete();
    return itemService;
}
 
Example #7
Source File: PackageController.java    From signature with MIT License 4 votes vote down vote up
/**
  * create by: iizvv
  * description: 创建获取UDID所用证书
  * create time: 2019-07-04 11:01

  * @return 证书名称
  */
String creatUDIDMobileconfig(long id) {
    System.out.println("创建获取UDID所用证书");
    String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
            "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n" +
            "<plist version=\"1.0\">\n" +
            "    <dict>\n" +
            "        <key>PayloadContent</key>\n" +
            "        <dict>\n" +
            "            <key>URL</key>\n" +
            "            <string>"+ Config.udidURL +"/udid/getUDID?id="+ id +"</string> <!--接收数据的接口地址-->\n" +
            "            <key>DeviceAttributes</key>\n" +
            "            <array>\n" +
            "                <string>SERIAL</string>\n" +
            "                <string>MAC_ADDRESS_EN0</string>\n" +
            "                <string>UDID</string>\n" +
            "                <string>IMEI</string>\n" +
            "                <string>ICCID</string>\n" +
            "                <string>VERSION</string>\n" +
            "                <string>PRODUCT</string>\n" +
            "            </array>\n" +
            "        </dict>\n" +
            "        <key>PayloadOrganization</key>\n" +
            "        <string>" + Config.payloadOrganization +"</string>  <!--组织名称-->\n" +
            "        <key>PayloadDisplayName</key>\n" +
            "        <string>" + Config.payloadDisplayName + "</string>  <!--安装时显示的标题-->\n" +
            "        <key>PayloadVersion</key>\n" +
            "        <integer>1</integer>\n" +
            "        <key>PayloadUUID</key>\n" +
            "        <string>"+ UUID.randomUUID().toString().replace("-", "") +"</string>  <!--自己随机填写的唯一字符串-->\n" +
            "        <key>PayloadIdentifier</key>\n" +
            "        <string>online.iizvv.profile-service</string>\n" +
            "        <key>PayloadDescription</key>\n" +
            "        <string>"+Config.payloadDescription+"</string>   <!--描述-->\n" +
            "        <key>PayloadType</key>\n" +
            "        <string>Profile Service</string>\n" +
            "    </dict>\n" +
            "</plist>";
    String tempName = "udid_"+ id + "_" + UUID.randomUUID().toString().replace("-", "");
    String tempMobileconfig = tempName + ".mobileconfig";
    FileWriter writer = new FileWriter(tempMobileconfig);
    writer.write(xml);
    System.out.println("开始执行shell");
    String mobileconfig = tempName + "_.mobileconfig";
    String com = "/root/mobileconfig.sh " + writer.getFile().getAbsolutePath() + " " + mobileconfig;
    try {
        Shell.run(com);
        System.out.println("shell执行成功, 文件位置为: " + mobileconfig);
        File file = new File("/root/" + mobileconfig);
        mobileconfig = uploadMobileconfig(file);
        file.delete();
    } catch (Exception e) {
        System.out.println("shell执行失败");
        mobileconfig = uploadMobileconfig(writer.getFile());
        e.printStackTrace();
    }finally {
        writer.getFile().delete();
    }
    System.out.println("mobileconfig文件上传结束");
    return mobileconfig;
}
 
Example #8
Source File: SignatureApplicationTests.java    From signature with MIT License 4 votes vote down vote up
void creatUDIDMobileconfig(long id) throws IOException, InterruptedException {
    String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
            "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n" +
            "<plist version=\"1.0\">\n" +
            "    <dict>\n" +
            "        <key>PayloadContent</key>\n" +
            "        <dict>\n" +
            "            <key>URL</key>\n" +
            "            <string>"+ Config.udidURL +"/udid/getUDID?id="+ id +"</string> <!--接收数据的接口地址-->\n" +
            "            <key>DeviceAttributes</key>\n" +
            "            <array>\n" +
            "                <string>SERIAL</string>\n" +
            "                <string>MAC_ADDRESS_EN0</string>\n" +
            "                <string>UDID</string>\n" +
            "                <string>IMEI</string>\n" +
            "                <string>ICCID</string>\n" +
            "                <string>VERSION</string>\n" +
            "                <string>PRODUCT</string>\n" +
            "            </array>\n" +
            "        </dict>\n" +
            "        <key>PayloadOrganization</key>\n" +
            "        <string>" + Config.payloadOrganization +"</string>  <!--组织名称-->\n" +
            "        <key>PayloadDisplayName</key>\n" +
            "        <string>" + Config.payloadDisplayName + "</string>  <!--安装时显示的标题-->\n" +
            "        <key>PayloadVersion</key>\n" +
            "        <integer>1</integer>\n" +
            "        <key>PayloadUUID</key>\n" +
            "        <string>"+ UUID.randomUUID().toString().replace("-", "") +"</string>  <!--自己随机填写的唯一字符串-->\n" +
            "        <key>PayloadIdentifier</key>\n" +
            "        <string>online.iizvv.profile-service</string>\n" +
            "        <key>PayloadDescription</key>\n" +
            "        <string>"+Config.payloadDescription+"</string>   <!--描述-->\n" +
            "        <key>PayloadType</key>\n" +
            "        <string>Profile Service</string>\n" +
            "    </dict>\n" +
            "</plist>";
    ClassLoader classLoader = this.getClass().getClassLoader();
    String name = "udid_"+id;
    String filePath = name + ".mobileconfig";
    FileWriter writer = new FileWriter(filePath);
    writer.write(xml);
    String serverKey = classLoader.getResource("server.key").getPath();
    String ca = classLoader.getResource("ca.crt").getPath();
    String serverCrt = classLoader.getResource("server.crt").getPath();
    String filePath2 = name+"_"+id +".mobileconfig";
    String com = "openssl smime -sign -in " + filePath +" -out "+ filePath2 + " -signer "+serverCrt+" -inkey "+serverKey+"  -certfile "+ca+" -outform der -nodetach";
    System.out.println(filePath2);
    Shell.run(com);
}
 
Example #9
Source File: PackageController.java    From signature with MIT License 3 votes vote down vote up
/**
  * create by: iizvv
  * description: 上传app
  * create time: 2019-06-28 17:21

  * @return app
  */
String uploadAppFile(File file) {
    System.out.println("开始上传原始ipa文件");
    String objName = UUID.randomUUID().toString().replace("-", "") + ".ipa";
    fileManager.uploadFile(file, objName, false);
    return objName;
}
 
Example #10
Source File: UDIDController.java    From signature with MIT License 2 votes vote down vote up
/**
 * create by: iizvv
 * description: 上传itemService
 * create time: 2019-07-04 11:18

 * @return plist名称
 */
String uploadItemService(File file) {
    String objName = UUID.randomUUID().toString().replace("-", "")+".plist";
    fileManager.uploadFile(file, objName);
    return objName;
}
 
Example #11
Source File: PackageController.java    From signature with MIT License 2 votes vote down vote up
/**
 * create by: iizvv
 * description: 上传icon
 * create time: 2019-06-29 12:19

 * @return icon名称
 */
String uploadIcon(File file) {
    String objName = UUID.randomUUID().toString().replace("-", "")+".png";
    fileManager.uploadFile(file, objName, false);
    return objName;
}
 
Example #12
Source File: PackageController.java    From signature with MIT License 2 votes vote down vote up
/**
  * create by: iizvv
  * description: 上传mobileconfig
  * create time: 2019-07-04 11:18

  * @return mobileconfig名称
  */
String uploadMobileconfig(File file) {
    String objName = UUID.randomUUID().toString().replace("-", "")+".mobileconfig";
    fileManager.uploadFile(file, objName, false);
    return objName;
}