0

我想通过对其应用加密将 blob 上传到 azure blob 存储中。所以我尝试使用以下代码来做到这一点:

 File f=new File("/home/prospera-user15/Desktop/test/download.jpeg");

        CloudStorageAccount account = CloudStorageAccount.parse(storageConnectionString);
        CloudBlobClient serviceClient = account.createCloudBlobClient();
        // Container name must be lower case.
        CloudBlobContainer container = serviceClient.getContainerReference("upload1");
        container.createIfNotExists();
        CloudBlockBlob blob = container.getBlockBlobReference("megha");
        final KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
        keyGen.initialize(2048);
        final KeyPair wrapKey = keyGen.generateKeyPair();

        RsaKey key = new RsaKey("RSA",wrapKey);
        System.out.println("Uploading the encrypted blob.");
        BlobEncryptionPolicy policy = new BlobEncryptionPolicy(key, null);
        BlobRequestOptions options = new BlobRequestOptions();
        options.setEncryptionPolicy(policy);
        AccessCondition accessCondition = null;
        OperationContext opContext = null;
        try{
            blob.upload(new FileInputStream(f), f.length(), accessCondition, options, opContext);
        }catch (IOException e) {
            System.out.println(e.getMessage());
        }catch (StorageException e) {
            System.out.println(e.getErrorCode());
        }

对于上面的代码,我得到了以下异常:

4

2 回答 2

0

当应用程序尝试调用抽象方法时会引发此异常。通常,这个错误会被编译器捕获;如果自上次编译当前执行的方法以来某些类的定义发生了不兼容的更改,则此错误只会在运行时发生。

来源:https ://docs.oracle.com/javase/6/docs/api/java/lang/AbstractMethodError.html

您是否还尝试检查您是否已根据此处的文档授权您的应用程序使用密钥或机密?

于 2018-01-29T18:16:13.287 回答
0

AbstractMethodError implies the definition of some class has incompatibly changed since last compilation

In your case, you might be using old version of an interface implementation which is missing a new interface method and as per stacktrace that might be your RsaKey class/interface.

于 2018-01-25T17:44:40.737 回答