• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java NSData类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.dd.plist.NSData的典型用法代码示例。如果您正苦于以下问题:Java NSData类的具体用法?Java NSData怎么用?Java NSData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



NSData类属于com.dd.plist包,在下文中一共展示了NSData类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: doPairSetupPin1

import com.dd.plist.NSData; //导入依赖的package包/类
private PairSetupPin1Response doPairSetupPin1(Socket socket) throws Exception {
    byte[] pairSetupPinRequestData = AuthUtils.createPList(new HashMap<String, String>() {{
        put("method", "pin");
        put("user", clientId);
    }});

    byte[] pairSetupPin1ResponseBytes = AuthUtils.postData(socket, "/pair-setup-pin", "application/x-apple-binary-plist", pairSetupPinRequestData);

    NSDictionary pairSetupPin1Response = (NSDictionary) PropertyListParser.parse(pairSetupPin1ResponseBytes);
    if (pairSetupPin1Response.containsKey("pk") && pairSetupPin1Response.containsKey("salt")) {
        byte[] pk = ((NSData) pairSetupPin1Response.get("pk")).bytes();
        byte[] salt = ((NSData) pairSetupPin1Response.get("salt")).bytes();
        return new PairSetupPin1Response(pk, salt);
    }
    throw new Exception();
}
 
开发者ID:funtax,项目名称:AirPlayAuth,代码行数:17,代码来源:AirPlayAuth.java


示例2: from

import com.dd.plist.NSData; //导入依赖的package包/类
public static Optional<InflatableData> from(byte[] bs) {
    InflatableData data;
    try {
        NSDictionary parse = (NSDictionary) PropertyListParser.parse(bs);
        byte[] escrowedKeys = ((NSData) parse.get("escrowedKeys")).bytes();
        UUID deviceUuid = UUID.fromString(((NSString) parse.get("deviceUuid")).getContent());
        String deviceHardWareId = ((NSString) parse.get("deviceHardWareId")).getContent();
        data = new InflatableData(escrowedKeys, deviceUuid, deviceHardWareId);

    } catch (ClassCastException | IllegalArgumentException | IOException | NullPointerException
            | PropertyListFormatException | ParseException | ParserConfigurationException | SAXException ex) {
        logger.warn("-- from() - exception: ", ex);
        data = null;
    }
    return Optional.ofNullable(data);
}
 
开发者ID:horrorho,项目名称:InflatableDonkey,代码行数:17,代码来源:InflatableData.java


示例3: doPairSetupPin2

import com.dd.plist.NSData; //导入依赖的package包/类
private PairSetupPin2Response doPairSetupPin2(Socket socket, final byte[] publicClientValueA, final byte[] clientEvidenceMessageM1) throws Exception {
    byte[] pairSetupPinRequestData = AuthUtils.createPList(new HashMap<String, byte[]>() {{
        put("pk", publicClientValueA);
        put("proof", clientEvidenceMessageM1);
    }});

    byte[] pairSetupPin2ResponseBytes = AuthUtils.postData(socket, "/pair-setup-pin", "application/x-apple-binary-plist", pairSetupPinRequestData);

    NSDictionary pairSetupPin2Response = (NSDictionary) PropertyListParser.parse(pairSetupPin2ResponseBytes);
    if (pairSetupPin2Response.containsKey("proof")) {
        byte[] proof = ((NSData) pairSetupPin2Response.get("proof")).bytes();
        return new PairSetupPin2Response(proof);
    }
    throw new Exception();
}
 
开发者ID:funtax,项目名称:AirPlayAuth,代码行数:16,代码来源:AirPlayAuth.java


示例4: doPairSetupPin3

import com.dd.plist.NSData; //导入依赖的package包/类
private PairSetupPin3Response doPairSetupPin3(Socket socket, final byte[] sessionKeyHashK) throws Exception {

        MessageDigest sha512Digest = MessageDigest.getInstance("SHA-512");
        sha512Digest.update("Pair-Setup-AES-Key".getBytes(StandardCharsets.UTF_8));
        sha512Digest.update(sessionKeyHashK);
        byte[] aesKey = Arrays.copyOfRange(sha512Digest.digest(), 0, 16);

        sha512Digest.update("Pair-Setup-AES-IV".getBytes(StandardCharsets.UTF_8));
        sha512Digest.update(sessionKeyHashK);
        byte[] aesIV = Arrays.copyOfRange(sha512Digest.digest(), 0, 16);

        int lengthB;
        int lengthA = lengthB = aesIV.length - 1;
        for (; lengthB >= 0 && 256 == ++aesIV[lengthA]; lengthA = lengthB += -1) ;

        Cipher aesGcm128Encrypt = Cipher.getInstance("AES/GCM/NoPadding");
        SecretKeySpec secretKey = new SecretKeySpec(aesKey, "AES");
        aesGcm128Encrypt.init(Cipher.ENCRYPT_MODE, secretKey, new GCMParameterSpec(128, aesIV));
        final byte[] aesGcm128ClientLTPK = aesGcm128Encrypt.doFinal(authKey.getAbyte());

        byte[] pairSetupPinRequestData = AuthUtils.createPList(new HashMap<String, byte[]>() {{
            put("epk", Arrays.copyOfRange(aesGcm128ClientLTPK, 0, aesGcm128ClientLTPK.length - 16));
            put("authTag", Arrays.copyOfRange(aesGcm128ClientLTPK, aesGcm128ClientLTPK.length - 16, aesGcm128ClientLTPK.length));
        }});

        byte[] pairSetupPin3ResponseBytes = AuthUtils.postData(socket, "/pair-setup-pin", "application/x-apple-binary-plist", pairSetupPinRequestData);

        NSDictionary pairSetupPin3Response = (NSDictionary) PropertyListParser.parse(pairSetupPin3ResponseBytes);

        if (pairSetupPin3Response.containsKey("epk") && pairSetupPin3Response.containsKey("authTag")) {
            byte[] epk = ((NSData) pairSetupPin3Response.get("epk")).bytes();
            byte[] authTag = ((NSData) pairSetupPin3Response.get("authTag")).bytes();

            return new PairSetupPin3Response(epk, authTag);
        }
        throw new Exception();
    }
 
开发者ID:funtax,项目名称:AirPlayAuth,代码行数:38,代码来源:AirPlayAuth.java


示例5: installCertProfile

import com.dd.plist.NSData; //导入依赖的package包/类
/** Installs a profile to set up an HTTPS certificate on the device. */
static void installCertProfile(RealDevice device, String certName, String certContentBase64)
    throws IosDeviceException {
  NSDictionary replacementDict = new NSDictionary();
  replacementDict.put("PayloadCertificateFileName", certName + ".cer");
  try {
    replacementDict.put("PayloadContent", new NSData(certContentBase64));
  } catch (IOException e) {
    throw new IosDeviceException(device, e);
  }
  replacementDict.put("PayloadDisplayName", certName);
  ConfigProfiles.installProfile(device, CERT_PROFILE_PATH, replacementDict);
}
 
开发者ID:google,项目名称:devtools-driver,代码行数:14,代码来源:ConfigProfiles.java


示例6: testIssue31_FalsePositiveForGZipInsideDataElement

import com.dd.plist.NSData; //导入依赖的package包/类
@Test
public void testIssue31_FalsePositiveForGZipInsideDataElement() throws Exception {
    File plistFile = new File("test-files/github-issue31.plist");

    NSDictionary dict = (NSDictionary)PropertyListParser.parse(plistFile);
    NSDictionary files = (NSDictionary)dict.get("files2");
    NSData hash = (NSData)((NSDictionary)files.get("Base.lproj/Main.storyboardc/MainController.nib")).get("hash");
    assertEquals("1f8b2ef69414fa70ff578a697cfc0919235c8eff", HexConverter.toHex(hash.bytes()));
}
 
开发者ID:3breadt,项目名称:dd-plist,代码行数:10,代码来源:IssueTest.java


示例7: kPCSMetadataEscrowedKeys

import com.dd.plist.NSData; //导入依赖的package包/类
static byte[] kPCSMetadataEscrowedKeys(NSDictionary metadata) {
    NSDictionary clientMetadata = PListsLegacy.getAs(metadata, "ClientMetadata", NSDictionary.class);

    NSDictionary secureBackupiCloudDataProtection
            = PListsLegacy.getAs(clientMetadata, "SecureBackupiCloudDataProtection", NSDictionary.class);

    return PListsLegacy.getAs(secureBackupiCloudDataProtection, "kPCSMetadataEscrowedKeys", NSData.class).bytes();
}
 
开发者ID:horrorho,项目名称:InflatableDonkey,代码行数:9,代码来源:ProtectedRecord.java


示例8: diagnostic

import com.dd.plist.NSData; //导入依赖的package包/类
static void diagnostic(byte[] metadata) {
    NSDictionary dictionary = PListsLegacy.parseDictionary(metadata);
    logger.debug("-- diagnostic() - dictionary: {}", dictionary.toXMLPropertyList());

    byte[] backupKeybagDigest = PListsLegacy.getAs(dictionary, "BackupKeybagDigest", NSData.class).bytes();
    logger.debug("-- diagnostic() - BackupKeybagDigest: 0x{}", Hex.toHexString(backupKeybagDigest));

    Optional<NSString> timestamp = PListsLegacy.optionalAs(dictionary, "com.apple.securebackup.timestamp", NSString.class);
    logger.debug("-- diagnostic() - com.apple.securebackup.timestamp: {}",
            timestamp.map(NSString::getContent));

    NSDictionary clientMetadata = PListsLegacy.getAs(dictionary, "ClientMetadata", NSDictionary.class);

    NSDictionary secureBackupiCloudDataProtection
            = PListsLegacy.getAs(clientMetadata, "SecureBackupiCloudDataProtection", NSDictionary.class);

    byte[] secureBackupiCloudIdentityPublicData
            = PListsLegacy.getAs(clientMetadata, "SecureBackupiCloudIdentityPublicData", NSData.class).bytes();

    Optional<PublicKeyInfo> optionalPublicKeyInfo
            = DERUtils.parse(secureBackupiCloudIdentityPublicData, PublicKeyInfo::new);
    logger.debug("-- diagnostic() - publicKeyInfo: {}", optionalPublicKeyInfo);

    byte[] kPCSMetadataEscrowedKeys
            = PListsLegacy.getAs(secureBackupiCloudDataProtection, "kPCSMetadataEscrowedKeys", NSData.class).bytes();
    logger.debug("-- diagnostic() - kPCSMetadataEscrowedKeys: 0x{}", Hex.toHexString(kPCSMetadataEscrowedKeys));
}
 
开发者ID:horrorho,项目名称:InflatableDonkey,代码行数:28,代码来源:ProtectedRecord.java


示例9: encoded

import com.dd.plist.NSData; //导入依赖的package包/类
public byte[] encoded() {
    try {
        NSDictionary dict = new NSDictionary();
        dict.put("escrowedKeys", new NSData(escrowedKeys));
        dict.put("deviceUuid", new NSString(deviceUuid.toString()));
        dict.put("deviceHardWareId", new NSString(deviceHardWareId));
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        PropertyListParser.saveAsBinary(dict, baos);
        return baos.toByteArray();
    } catch (IOException ex) {
        throw new IllegalStateException(ex);
    }
}
 
开发者ID:horrorho,项目名称:InflatableDonkey,代码行数:14,代码来源:InflatableData.java


示例10: verify

import com.dd.plist.NSData; //导入依赖的package包/类
protected void verify(final NSDictionary dictionary, final String publicKey) throws InvalidLicenseException {
    if(null == dictionary) {
        throw new InvalidLicenseException();
    }
    final NSData signature = (NSData) dictionary.objectForKey("Signature");
    if(null == signature) {
        log.warn(String.format("Missing key 'Signature' in dictionary %s", dictionary));
        throw new InvalidLicenseException();
    }
    // Append all values
    StringBuilder values = new StringBuilder();
    final ArrayList<String> keys = new ArrayList<>(dictionary.keySet());
    // Sort lexicographically by key
    Collections.sort(keys, new NaturalOrderComparator());
    for(String key : keys) {
        if("Signature".equals(key)) {
            continue;
        }
        values.append(dictionary.objectForKey(key).toString());
    }
    byte[] signaturebytes = signature.bytes();
    byte[] plainbytes = values.toString().getBytes(Charset.forName("UTF-8"));
    try {
        final BigInteger modulus = new BigInteger(StringUtils.removeStart(publicKey, "0x"), 16);
        final BigInteger exponent = new BigInteger(Base64.decodeBase64("Aw=="));
        final KeySpec spec = new RSAPublicKeySpec(modulus, exponent);

        final PublicKey rsa = KeyFactory.getInstance("RSA").generatePublic(spec);
        final Cipher rsaCipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
        rsaCipher.init(Cipher.DECRYPT_MODE, rsa);
        final MessageDigest sha1Digest = MessageDigest.getInstance("SHA1");
        if(!Arrays.equals(rsaCipher.doFinal(signaturebytes), sha1Digest.digest(plainbytes))) {
            throw new InvalidLicenseException();
        }
    }
    catch(NoSuchPaddingException
            | BadPaddingException
            | IllegalBlockSizeException
            | InvalidKeyException
            | InvalidKeySpecException
            | NoSuchAlgorithmException e) {
        log.warn(String.format("Signature verification failure for key %s", file));
        throw new InvalidLicenseException();
    }
    if(log.isInfoEnabled()) {
        log.info(String.format("Valid key in %s", file));
    }
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:49,代码来源:DictionaryLicense.java


示例11: fromDictionary

import com.dd.plist.NSData; //导入依赖的package包/类
public static AssetEncryptedAttributes fromDictionary(NSDictionary data, String domain) {
    logger.trace("<< fromDictionary() - data:{} domain: {}", data.toXMLPropertyList(), domain);
    NSDictionaries.as(data, "domain", NSString.class)
            .map(NSString::getContent)
            .filter(u -> !u.equals(domain))
            .ifPresent(u -> logger.warn("-- fromDictionary() - domain mismatch: {} != {}", u, domain));
    Optional<String> relativePath = NSDictionaries.as(data, "relativePath", NSString.class)
            .map(NSString::getContent);
    Optional<Instant> modified = NSDictionaries.as(data, "modified", NSDate.class)
            .map(NSDate::getDate)
            .map(Date::toInstant);
    Optional<Instant> birth = NSDictionaries.as(data, "birth", NSDate.class)
            .map(NSDate::getDate)
            .map(Date::toInstant);
    Optional<Instant> statusChanged = NSDictionaries.as(data, "statusChanged", NSDate.class)
            .map(NSDate::getDate)
            .map(Date::toInstant);
    Optional<Integer> userID = NSDictionaries.as(data, "userID", NSNumber.class)
            .map(NSNumber::intValue);
    Optional<Integer> groupID = NSDictionaries.as(data, "groupID", NSNumber.class)
            .map(NSNumber::intValue);
    Optional<Integer> mode = NSDictionaries.as(data, "mode", NSNumber.class)
            .map(NSNumber::intValue);
    Optional<Long> size = NSDictionaries.as(data, "size", NSNumber.class)
            .map(NSNumber::longValue);
    Optional<byte[]> encryptionKey = NSDictionaries.as(data, "encryptionKey", NSData.class)
            .map(NSData::bytes);
    Optional<byte[]> checksum = Optional.empty();   // not present
    Optional<Long> sizeBeforeCopy = Optional.empty();   // not present
    Optional<Integer> contentEncodingMethod = Optional.empty();   // not present
    Optional<Integer> contentCompressionMethod = Optional.empty();   // not present

    AssetEncryptedAttributes attributes = new AssetEncryptedAttributes(
            Optional.of(domain),
            relativePath,
            modified,
            birth,
            statusChanged,
            userID,
            groupID,
            mode,
            size,
            encryptionKey,
            checksum,
            sizeBeforeCopy,
            contentEncodingMethod,
            contentCompressionMethod);
    logger.trace(">> fromDictionary() - encrypted attributes: {}", attributes);
    return attributes;
}
 
开发者ID:horrorho,项目名称:InflatableDonkey,代码行数:51,代码来源:AssetEncryptedAttributesFactory.java


示例12: data

import com.dd.plist.NSData; //导入依赖的package包/类
public static PropertyListResponseHandler<NSData> data() {
    return DATA;
}
 
开发者ID:horrorho,项目名称:InflatableDonkey,代码行数:4,代码来源:PropertyListResponseHandler.java



注:本文中的com.dd.plist.NSData类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Store类代码示例发布时间:2022-05-22
下一篇:
Java GreekStemFilter类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap