You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// TODO: Implement and Verify the usage.// get the latest version of a keyKeykey = keyAsyncClient.getKey("user1Key").block().value();
// get a specific version of a keyKeykeyWithVersion = keyAsyncClient.getKey("user1Key","6A385B124DEF4096AF1361A85B16C204").block().value();
// TODO: Implement and Verify the usage.// Update the expiration of a keyKeyuserKey = keyAsyncClient.getKey("user1Key").block().value();
userKey.notBefore(OffsetDateTime.now().plusDays(79));
KeyBaseupdatedKey = keyAsyncClient.updateKey(userKey).block().value();
// TODO: Implement and Verify the usage.// Delete a keyDeletedKeydeletedkey = keyAsyncClient.deleteKey("user1pass").block().value();
// Wait for few seconds.Thread.sleep(5000);
// Get the details of a deleted keydeletedKey = keyAsyncClient.getDeletedKey("user1pass").block().value();
// List all the deleted keyskeyAsyncClient.listDeletedKeys()
.subscribe(delKey -> System.out.println(delKey.recoveryId()));
// Recover a deleted keyKeykey = keyAsyncClient.recoverDeletedKey("user1pass").block().value();
// Wait for few seconds.Thread.sleep(5000);
// Delete the key again after recovering it.deletedKey = keyAsyncClient.deleteKey("user1pass").block().value();
// Wait for few seconds.Thread.sleep(5000);
// Purge the deleted key -- permanenetly delete it.keyAsyncClient.purgeDeletedKey("user1pass").block();
// TODO: Implement and Verify the usage.// backup the keybyte[] backup = keyAsyncClient.backupKey("user1Key").block().value();
DeletedKeydeletedKey = keyAsyncClient.deleteKey("user1Key").block().value();
Thread.sleep(30000);
keyAsyncClient.purgeDeletedKey("user1Key").block();
//restore the key from backupKeyrestored = keyAsyncClient.restoreKey(backup).block().value();
// TODO: Add Track one Backup and Restore Key usage examples.
DataStructures:
publicclassKeyBase {
//TODO: Add appropriate setters for the variables/** * Key identifier. */@JsonProperty(value = "kid")
privateStringkid;
/** * Type of the key. */@JsonProperty(value = "contentType")
privateStringcontentType;
/** * Application specific metadata in the form of key-value pairs. */@JsonProperty(value = "tags")
privateMap<String, String> tags;
/** * True if the key's lifetime is managed by key vault. If this is a key * backing a certificate, then managed will be true. */@JsonProperty(value = "managed", access = JsonProperty.Access.WRITE_ONLY)
privateBooleanmanaged;
/** * Determines whether the object is enabled. */@JsonProperty(value = "enabled")
privateBooleanenabled;
/** * Not before date in UTC. */@JsonProperty(value = "nbf")
privateLongnotBefore;
/** * Expiry date in UTC. */@JsonProperty(value = "exp")
privateLongexpires;
/** * Creation time in UTC. */@JsonProperty(value = "created", access = JsonProperty.Access.WRITE_ONLY)
privateLongcreated;
/** * Last updated time in UTC. */@JsonProperty(value = "updated", access = JsonProperty.Access.WRITE_ONLY)
privateLongupdated;
/** * Reflects the deletion recovery level currently in effect for keys in the * current vault. If it contains 'Purgeable' the key can be permanently * deleted by a privileged user; otherwise, only the system can purge the * key, at the end of the retention interval. Possible values include: * 'Purgeable', 'Recoverable+Purgeable', 'Recoverable', * 'Recoverable+ProtectedSubscription'. */@JsonProperty(value = "recoveryLevel", access = JsonProperty.Access.WRITE_ONLY)
privateStringrecoveryLevel;
/** * Get the recoveryLevel value. * * @return the recoveryLevel value */publicDeletionRecoveryLevelrecoveryLevel() {
returnthis.recoveryLevel;
}
}
publicclassKeyextendsKeyBase {
privateIntegerkeySize;
privateList<JsonWebKeyOperation> keyOperations;
privateJsonWebKeyCurveNamecurve;
@JsonProperty(value = "key")
privateJsonWebKeykeyMaterial;
publicKey(Stringname, JsonWebKeyTypekeyType) {}
publicKeykeySize(IntegerkeySize){
this.keySize = keySize;
returnthis;
}
//Add setters in similar way for other variables
}
publicclassKeyImportextendsKeyBase {
privatebooleanhsm;
@JsonProperty(value = "key")
privateJsonWebKeykey;
publicKeyImport(Stringname, JsonWebKeykey) {}
publicKeyImporthsm(booleanhsm) {
this.hsm = hsm;
returnthis;
}
// Add other required setters.
}
publicfinalclassDeletedKeyextendsKeyBase {
/** * The url of the recovery object, used to identify and recover the deleted * key. */@JsonProperty(value = "recoveryId")
privateStringrecoveryId;
/** * The time when the key is scheduled to be purged, in UTC. */@JsonProperty(value = "scheduledPurgeDate", access = JsonProperty.Access.WRITE_ONLY)
privateLongscheduledPurgeDate;
/** * The time when the key was deleted, in UTC. */@JsonProperty(value = "deletedDate", access = JsonProperty.Access.WRITE_ONLY)
privateLongdeletedDate;
/** * Get the recoveryId value. * * @return the recoveryId value */publicStringrecoveryId() {
returnthis.recoveryId;
}
// Add other required Setters
}