@@ -129,48 +129,44 @@ Mono<EncryptResult> encrypt(EncryptOptions encryptOptions, Context context) {
129129 Objects .requireNonNull (encryptOptions , "'encryptOptions' cannot be null." );
130130
131131 EncryptionAlgorithm algorithm = encryptOptions .getAlgorithm ();
132- byte [] iv = encryptOptions .getIv ();
133- byte [] authenticatedData = encryptOptions .getAdditionalAuthenticatedData ();
134132 KeyOperationParameters parameters = new KeyOperationParameters ()
135133 .setAlgorithm (algorithm )
136134 .setValue (encryptOptions .getPlainText ())
137- .setIv (iv )
138- .setAdditionalAuthenticatedData (authenticatedData );
135+ .setIv (encryptOptions . getIv () )
136+ .setAdditionalAuthenticatedData (encryptOptions . getAdditionalAuthenticatedData () );
139137 context = context == null ? Context .NONE : context ;
140138
141139 return service .encrypt (vaultUrl , keyName , version , apiVersion , ACCEPT_LANGUAGE , parameters ,
142140 CONTENT_TYPE_HEADER_VALUE , context .addData (AZ_TRACING_NAMESPACE_KEY , KEYVAULT_TRACING_NAMESPACE_VALUE ))
143- .doOnRequest (ignored -> logger .info ("Encrypting content with algorithm - {}" , algorithm .toString ()))
144- .doOnSuccess (response -> logger .info ("Retrieved encrypted content with algorithm- {}" ,
145- algorithm .toString ()))
146- .doOnError (error -> logger .warning ("Failed to encrypt content with algorithm - {}" , algorithm .toString (),
147- error ))
148- .flatMap (keyOperationResultResponse ->
149- Mono .just (new EncryptResult (keyOperationResultResponse .getValue ().getResult (), algorithm , keyId )));
141+ .doOnRequest (ignored -> logger .info ("Encrypting content with algorithm - {}" , algorithm ))
142+ .doOnSuccess (response -> logger .info ("Retrieved encrypted content with algorithm - {}" , algorithm ))
143+ .doOnError (error -> logger .warning ("Failed to encrypt content with algorithm - {}" , algorithm , error ))
144+ .map (keyOperationResultResponse -> {
145+ KeyOperationResult keyOperationResult = keyOperationResultResponse .getValue ();
146+
147+ return new EncryptResult (keyOperationResult .getResult (), algorithm , keyId ,
148+ keyOperationResult .getIv (), keyOperationResult .getAdditionalAuthenticatedData (),
149+ keyOperationResult .getAuthenticationTag ());
150+ });
150151 }
151152
152153 Mono <DecryptResult > decrypt (DecryptOptions decryptOptions , Context context ) {
153154 Objects .requireNonNull (decryptOptions , "'decryptOptions' cannot be null." );
154155
155156 EncryptionAlgorithm algorithm = decryptOptions .getAlgorithm ();
156- byte [] iv = decryptOptions .getIv ();
157- byte [] additionalAuthenticatedData = decryptOptions .getAdditionalAuthenticatedData ();
158- byte [] authenticationTag = decryptOptions .getAuthenticationTag ();
159157 KeyOperationParameters parameters = new KeyOperationParameters ()
160158 .setAlgorithm (algorithm )
161159 .setValue (decryptOptions .getCipherText ())
162- .setIv (iv )
163- .setAdditionalAuthenticatedData (additionalAuthenticatedData )
164- .setAuthenticationTag (authenticationTag );
160+ .setIv (decryptOptions . getIv () )
161+ .setAdditionalAuthenticatedData (decryptOptions . getAdditionalAuthenticatedData () )
162+ .setAuthenticationTag (decryptOptions . getAuthenticationTag () );
165163 context = context == null ? Context .NONE : context ;
166164
167165 return service .decrypt (vaultUrl , keyName , version , apiVersion , ACCEPT_LANGUAGE , parameters ,
168166 CONTENT_TYPE_HEADER_VALUE , context .addData (AZ_TRACING_NAMESPACE_KEY , KEYVAULT_TRACING_NAMESPACE_VALUE ))
169- .doOnRequest (ignored -> logger .info ("Decrypting content with algorithm - {}" , algorithm .toString ()))
170- .doOnSuccess (response -> logger .info ("Retrieved decrypted content with algorithm- {}" ,
171- algorithm .toString ()))
172- .doOnError (error -> logger .warning ("Failed to decrypt content with algorithm - {}" , algorithm .toString (),
173- error ))
167+ .doOnRequest (ignored -> logger .info ("Decrypting content with algorithm - {}" , algorithm ))
168+ .doOnSuccess (response -> logger .info ("Retrieved decrypted content with algorithm - {}" , algorithm ))
169+ .doOnError (error -> logger .warning ("Failed to decrypt content with algorithm - {}" , algorithm , error ))
174170 .flatMap (keyOperationResultResponse -> Mono .just (
175171 new DecryptResult (keyOperationResultResponse .getValue ().getResult (), algorithm , keyId )));
176172 }
@@ -180,27 +176,25 @@ Mono<SignResult> sign(SignatureAlgorithm algorithm, byte[] digest, Context conte
180176 context = context == null ? Context .NONE : context ;
181177 return service .sign (vaultUrl , keyName , version , apiVersion , ACCEPT_LANGUAGE , parameters ,
182178 CONTENT_TYPE_HEADER_VALUE , context .addData (AZ_TRACING_NAMESPACE_KEY , KEYVAULT_TRACING_NAMESPACE_VALUE ))
183- .doOnRequest (ignored -> logger .info ("Signing content with algorithm - {}" , algorithm .toString ()))
184- .doOnSuccess (response -> logger .info ("Retrieved signed content with algorithm- {}" , algorithm .toString ()))
185- .doOnError (error -> logger .warning ("Failed to sign content with algorithm - {}" , algorithm .toString (),
186- error ))
179+ .doOnRequest (ignored -> logger .info ("Signing content with algorithm - {}" , algorithm ))
180+ .doOnSuccess (response -> logger .info ("Retrieved signed content with algorithm - {}" , algorithm ))
181+ .doOnError (error -> logger .warning ("Failed to sign content with algorithm - {}" , algorithm , error ))
187182 .flatMap (keyOperationResultResponse ->
188183 Mono .just (new SignResult (keyOperationResultResponse .getValue ().getResult (), algorithm , keyId )));
189184 }
190185
191186 Mono <VerifyResult > verify (SignatureAlgorithm algorithm , byte [] digest , byte [] signature , Context context ) {
192187
193- KeyVerifyRequest parameters = new KeyVerifyRequest ().setAlgorithm (algorithm ).setDigest (digest ).setSignature (signature );
188+ KeyVerifyRequest parameters =
189+ new KeyVerifyRequest ().setAlgorithm (algorithm ).setDigest (digest ).setSignature (signature );
194190 context = context == null ? Context .NONE : context ;
195191
196192 return service .verify (vaultUrl , keyName , version , apiVersion , ACCEPT_LANGUAGE , parameters ,
197193 CONTENT_TYPE_HEADER_VALUE , context .addData (AZ_TRACING_NAMESPACE_KEY , KEYVAULT_TRACING_NAMESPACE_VALUE ))
198- .doOnRequest (ignored -> logger .info ("Verifying content with algorithm - {}" , algorithm .toString ()))
199- .doOnSuccess (response -> logger .info ("Retrieved verified content with algorithm- {}" , algorithm .toString ()))
200- .doOnError (error -> logger .warning ("Failed to verify content with algorithm - {}" , algorithm .toString (),
201- error ))
202- .flatMap (response ->
203- Mono .just (new VerifyResult (response .getValue ().getValue (), algorithm , keyId )));
194+ .doOnRequest (ignored -> logger .info ("Verifying content with algorithm - {}" , algorithm ))
195+ .doOnSuccess (response -> logger .info ("Retrieved verified content with algorithm - {}" , algorithm ))
196+ .doOnError (error -> logger .warning ("Failed to verify content with algorithm - {}" , algorithm , error ))
197+ .flatMap (response -> Mono .just (new VerifyResult (response .getValue ().getValue (), algorithm , keyId )));
204198 }
205199
206200 Mono <WrapResult > wrapKey (KeyWrapAlgorithm algorithm , byte [] key , Context context ) {
@@ -211,31 +205,25 @@ Mono<WrapResult> wrapKey(KeyWrapAlgorithm algorithm, byte[] key, Context context
211205
212206 return service .wrapKey (vaultUrl , keyName , version , apiVersion , ACCEPT_LANGUAGE , parameters ,
213207 CONTENT_TYPE_HEADER_VALUE , context .addData (AZ_TRACING_NAMESPACE_KEY , KEYVAULT_TRACING_NAMESPACE_VALUE ))
214- .doOnRequest (ignored -> logger .info ("Wrapping key content with algorithm - {}" , algorithm .toString ()))
215- .doOnSuccess (response -> logger .info ("Retrieved wrapped key content with algorithm- {}" ,
216- algorithm .toString ()))
217- .doOnError (error -> logger .warning ("Failed to verify content with algorithm - {}" , algorithm .toString (),
218- error ))
208+ .doOnRequest (ignored -> logger .info ("Wrapping key content with algorithm - {}" , algorithm ))
209+ .doOnSuccess (response -> logger .info ("Retrieved wrapped key content with algorithm - {}" , algorithm ))
210+ .doOnError (error -> logger .warning ("Failed to verify content with algorithm - {}" , algorithm , error ))
219211 .flatMap (keyOperationResultResponse ->
220212 Mono .just (new WrapResult (keyOperationResultResponse .getValue ().getResult (), algorithm , keyId )));
221213 }
222214
223215 Mono <UnwrapResult > unwrapKey (KeyWrapAlgorithm algorithm , byte [] encryptedKey , Context context ) {
224-
225216 KeyWrapUnwrapRequest parameters = new KeyWrapUnwrapRequest ()
226217 .setAlgorithm (algorithm )
227218 .setValue (encryptedKey );
228219 context = context == null ? Context .NONE : context ;
229220
230221 return service .unwrapKey (vaultUrl , keyName , version , apiVersion , ACCEPT_LANGUAGE , parameters ,
231222 CONTENT_TYPE_HEADER_VALUE , context .addData (AZ_TRACING_NAMESPACE_KEY , KEYVAULT_TRACING_NAMESPACE_VALUE ))
232- .doOnRequest (ignored -> logger .info ("Unwrapping key content with algorithm - {}" , algorithm .toString ()))
233- .doOnSuccess (response -> logger .info ("Retrieved unwrapped key content with algorithm- {}" ,
234- algorithm .toString ()))
235- .doOnError (error -> logger .warning ("Failed to unwrap key content with algorithm - {}" ,
236- algorithm .toString (), error ))
237- .flatMap (response ->
238- Mono .just (new UnwrapResult (response .getValue ().getResult (), algorithm , keyId )));
223+ .doOnRequest (ignored -> logger .info ("Unwrapping key content with algorithm - {}" , algorithm ))
224+ .doOnSuccess (response -> logger .info ("Retrieved unwrapped key content with algorithm - {}" , algorithm ))
225+ .doOnError (error -> logger .warning ("Failed to unwrap key content with algorithm - {}" , algorithm , error ))
226+ .flatMap (response -> Mono .just (new UnwrapResult (response .getValue ().getResult (), algorithm , keyId )));
239227 }
240228
241229
0 commit comments