Package com.microsoft.windowsazure.services.media.models

Examples of com.microsoft.windowsazure.services.media.models.AccessPolicyInfo


    }

    @Test
    public void canCreateAssetWithMultipleFiles() throws Exception {
        AssetInfo asset = createTestAsset("createWithMultipleFiles");
        AccessPolicyInfo policy = createWritePolicy("createWithMultipleFiles",
                10);
        LocatorInfo locator = createLocator(policy, asset, 5);

        WritableBlobContainerContract blobWriter = service
                .createBlobWriter(locator);
View Full Code Here


    }

    @Test
    public void canCreateFileAndThenUpdateIt() throws Exception {
        AssetInfo asset = createTestAsset("createAndUpdate");
        AccessPolicyInfo policy = createWritePolicy("createAndUpdate", 10);
        LocatorInfo locator = createLocator(policy, asset, 5);
        WritableBlobContainerContract blobWriter = service
                .createBlobWriter(locator);

        createAndUploadBlob(blobWriter, "toUpdate.bin", firstPrimes);
View Full Code Here

    }

    @Test
    public void canDeleteFileFromAsset() throws Exception {
        AssetInfo asset = createTestAsset("deleteFile");
        AccessPolicyInfo policy = createWritePolicy("deleteFile", 10);
        LocatorInfo locator = createLocator(policy, asset, 5);
        WritableBlobContainerContract blobWriter = service
                .createBlobWriter(locator);

        createAndUploadBlob(blobWriter, "todelete.bin", firstPrimes);
View Full Code Here

    }

    public void uploadFilesToAsset(AssetInfo asset, int uploadWindowInMinutes,
            Hashtable<String, InputStream> inputFiles, byte[] aesKey)
            throws Exception {
        AccessPolicyInfo accessPolicy = service.create(AccessPolicy.create(
                accessPolicyPrefix + "tempAccessPolicy", uploadWindowInMinutes,
                EnumSet.of(AccessPolicyPermission.WRITE)));
        LocatorInfo locator = service.create(Locator.create(
                accessPolicy.getId(), asset.getId(), LocatorType.SAS));

        String contentKeyId = createAssetContentKey(asset, aesKey);

        WritableBlobContainerContract uploader = service
                .createBlobWriter(locator);

        Hashtable<String, AssetFileInfo> infoToUpload = new Hashtable<String, AssetFileInfo>();

        boolean isFirst = true;
        for (String fileName : inputFiles.keySet()) {
            MessageDigest digest = MessageDigest.getInstance("MD5");

            InputStream inputStream = inputFiles.get(fileName);

            byte[] iv = null;
            if (aesKey != null) {
                iv = createIV();
                inputStream = EncryptionHelper.encryptFile(inputStream, aesKey,
                        iv);
            }

            InputStream digestStream = new DigestInputStream(inputStream,
                    digest);
            CountingStream countingStream = new CountingStream(digestStream);
            uploader.createBlockBlob(fileName, countingStream);

            inputStream.close();
            byte[] md5hash = digest.digest();
            String md5 = Base64.encode(md5hash);

            AssetFileInfo fi = new AssetFileInfo(null, new AssetFileType()
                    .setContentChecksum(md5)
                    .setContentFileSize(countingStream.getCount())
                    .setIsPrimary(isFirst).setName(fileName)
                    .setInitializationVector(getIVString(iv)));
            infoToUpload.put(fileName, fi);

            isFirst = false;
        }

        service.action(AssetFile.createFileInfos(asset.getId()));
        for (AssetFileInfo assetFile : service.list(AssetFile.list(asset
                .getAssetFilesLink()))) {
            AssetFileInfo fileInfo = infoToUpload.get(assetFile.getName());
            Updater updateOp = AssetFile.update(assetFile.getId())
                    .setContentChecksum(fileInfo.getContentChecksum())
                    .setContentFileSize(fileInfo.getContentFileSize())
                    .setIsPrimary(fileInfo.getIsPrimary());

            if (aesKey != null) {
                updateOp.setIsEncrypted(true)
                        .setEncryptionKeyId(contentKeyId)
                        .setEncryptionScheme("StorageEncryption")
                        .setEncryptionVersion("1.0")
                        .setInitializationVector(
                                fileInfo.getInitializationVector());
            }

            service.update(updateOp);
        }

        service.list(AssetFile.list(asset.getAssetFilesLink()));

        service.delete(Locator.delete(locator.getId()));
        service.delete(AccessPolicy.delete(accessPolicy.getId()));
    }
View Full Code Here

    private Hashtable<String, URL> createFileURLsFromAsset(AssetInfo asset,
            int availabilityWindowInMinutes) throws ServiceException,
            MalformedURLException {
        Hashtable<String, URL> ret = new Hashtable<String, URL>();

        AccessPolicyInfo readAP = service.create(AccessPolicy.create(
                accessPolicyPrefix + "tempAccessPolicy",
                availabilityWindowInMinutes,
                EnumSet.of(AccessPolicyPermission.READ)));
        LocatorInfo readLocator = service.create(Locator.create(readAP.getId(),
                asset.getId(), LocatorType.SAS));

        List<AssetFileInfo> publishedFiles = service.list(AssetFile.list(asset
                .getAssetFilesLink()));
        for (AssetFileInfo fi : publishedFiles) {
View Full Code Here

        IntegrationTestBase.setup();

        AssetInfo asset = service.create(Asset.create().setName(
                testAssetPrefix + "uploadBlockBlobAsset"));

        AccessPolicyInfo policy = service.create(AccessPolicy.create(
                testPolicyPrefix + "uploadWritePolicy", 10,
                EnumSet.of(AccessPolicyPermission.WRITE)));

        LocatorInfo locator = createLocator(policy, asset, 5);
View Full Code Here

        String name = UUID.randomUUID().toString();
        String testBlobName = "test" + name + ".bin";
        AssetInfo assetInfo = service.create(Asset.create().setName(
                testAssetPrefix + name));

        AccessPolicyInfo accessPolicyInfo = service.create(AccessPolicy.create(
                testPolicyPrefix + name, 10,
                EnumSet.of(AccessPolicyPermission.WRITE)));
        LocatorInfo locator = createLocator(accessPolicyInfo, assetInfo, 5);
        WritableBlobContainerContract blobWriter = service
                .createBlobWriter(locator);
View Full Code Here

                + "canGetParentBackFromAsset";
        AssetInfo originalAsset = service.create(Asset.create().setName(
                originalAssetName));

        int durationInMinutes = 10;
        AccessPolicyInfo accessPolicyInfo = service.create(AccessPolicy.create(
                testPolicyPrefix + "uploadAesPortectedAssetSuccess",
                durationInMinutes, EnumSet.of(AccessPolicyPermission.WRITE)));

        LocatorInfo locatorInfo = service.create(Locator.create(
                accessPolicyInfo.getId(), originalAsset.getId(),
                LocatorType.SAS));
        WritableBlobContainerContract blobWriter = service
                .createBlobWriter(locatorInfo);

        InputStream mpeg4H264InputStream = getClass().getResourceAsStream(
View Full Code Here

    @Test
    public void canCreateAccessPolicy() throws Exception {
        String testName = testPolicyPrefix + "CanCreate";
        double duration = 5;

        AccessPolicyInfo policy = service.create(AccessPolicy.create(testName,
                duration, EnumSet.of(AccessPolicyPermission.WRITE)));

        verifyPolicyProperties("policy", testName, duration,
                AccessPolicyPermission.WRITE, policy);
    }
View Full Code Here

    @Test
    public void canCreateAccessPolicyWithReadPermissions() throws Exception {
        String testName = testPolicyPrefix + "CanCreateRead";
        double duration = 5;

        AccessPolicyInfo policy = service.create(AccessPolicy.create(testName,
                duration, EnumSet.of(AccessPolicyPermission.READ)));

        verifyPolicyProperties("policy", testName, duration,
                AccessPolicyPermission.READ, policy);
    }
View Full Code Here

TOP

Related Classes of com.microsoft.windowsazure.services.media.models.AccessPolicyInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.