From fc7d340a898ce44f3f1f093f480c8356a195a56f Mon Sep 17 00:00:00 2001
From: luchua-bc
+ The following code example connects to AWS using a hard-coded access key ID and secret key: +
+ ++ Instead, the access key ID and secret key could be supplied through environment variables, + which can be set externally without hard-coding credentials in the source code. +
+ ++ The following code example connects to Azure using a hard-coded user name and password or client secret: +
+ ++ Instead, the username and password or client secret could be supplied through environment variables, + which can be set externally without hard-coding credentials in the source code. +
Sample: Construct a simple ClientSecretCredential
+ * {@codesnippet com.azure.identity.credential.clientsecretcredential.construct} + * + *Sample: Construct a ClientSecretCredential behind a proxy
+ * {@codesnippet com.azure.identity.credential.clientsecretcredential.constructwithproxy} + */ +public class ClientSecretCredential implements TokenCredential { +} diff --git a/java/ql/test/stubs/azure-sdk-for-java/com/azure/identity/ClientSecretCredentialBuilder.java b/java/ql/test/stubs/azure-sdk-for-java/com/azure/identity/ClientSecretCredentialBuilder.java new file mode 100644 index 00000000000..85ab73c3060 --- /dev/null +++ b/java/ql/test/stubs/azure-sdk-for-java/com/azure/identity/ClientSecretCredentialBuilder.java @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.identity; + +/** + * Fluent credential builder for instantiating a {@link ClientSecretCredential}. + * + * @see ClientSecretCredential + */ +public class ClientSecretCredentialBuilder extends AadCredentialBuilderBasecacheFileLocation() instead of
+ * Gnome keyring on Linux. This is restricted by default.
+ *
+ * @return An updated instance of this builder.
+ */
+ ClientSecretCredentialBuilder allowUnencryptedCache() {
+ return null;
+ }
+
+ /**
+ * Configures the persistent shared token cache options and enables the persistent token cache which is disabled
+ * by default. If configured, the credential will store tokens in a cache persisted to the machine, protected to
+ * the current user, which can be shared by other credentials and processes.
+ *
+ * @param tokenCachePersistenceOptions the token cache configuration options
+ * @return An updated instance of this builder with the token cache options configured.
+ */
+ public ClientSecretCredentialBuilder tokenCachePersistenceOptions(TokenCachePersistenceOptions
+ tokenCachePersistenceOptions) {
+ return null;
+ }
+
+ /**
+ * Creates a new {@link ClientCertificateCredential} with the current configurations.
+ *
+ * @return a {@link ClientSecretCredentialBuilder} with the current configurations.
+ */
+ public ClientSecretCredential build() {
+ return null;
+ }
+}
diff --git a/java/ql/test/stubs/azure-sdk-for-java/com/azure/identity/CredentialBuilderBase.java b/java/ql/test/stubs/azure-sdk-for-java/com/azure/identity/CredentialBuilderBase.java
new file mode 100644
index 00000000000..c1210942ea0
--- /dev/null
+++ b/java/ql/test/stubs/azure-sdk-for-java/com/azure/identity/CredentialBuilderBase.java
@@ -0,0 +1,13 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+package com.azure.identity;
+
+/**
+ * The base class for all the credential builders.
+ * @param cacheFileLocation() instead of
+ * Gnome keyring on Linux. This is restricted by default. For other platforms this setting currently doesn't apply.
+ *
+ * @param unencryptedStorageAllowed The flag indicating if unencrypted storage is allowed for the cache or not.
+ * @return An updated instance of the options bag.
+ */
+ public TokenCachePersistenceOptions setUnencryptedStorageAllowed(boolean unencryptedStorageAllowed) {
+ return null;
+ }
+
+ /**
+ * Gets the status whether unencrypted storage is allowed for the persistent token cache.
+ *
+ * @return The status indicating if unencrypted storage is allowed for the persistent token cache.
+ */
+ public boolean isUnencryptedStorageAllowed() {
+ return false;
+ }
+
+ /**
+ * Set the name uniquely identifying the cache.
+ *
+ * @param name the name of the cache
+ * @return the updated instance of the cache.
+ */
+ public TokenCachePersistenceOptions setName(String name) {
+ return null;
+ }
+
+ /**
+ * Get the name uniquely identifying the cache.
+ *
+ * @return the name of the cache.
+ */
+ public String getName() {
+ return null;
+ }
+}
diff --git a/java/ql/test/stubs/azure-sdk-for-java/com/azure/identity/UsernamePasswordCredential.java b/java/ql/test/stubs/azure-sdk-for-java/com/azure/identity/UsernamePasswordCredential.java
new file mode 100644
index 00000000000..5cb9463eb95
--- /dev/null
+++ b/java/ql/test/stubs/azure-sdk-for-java/com/azure/identity/UsernamePasswordCredential.java
@@ -0,0 +1,14 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+package com.azure.identity;
+
+import com.azure.core.credential.TokenCredential;
+
+/**
+ * An AAD credential that acquires a token with a username and a password. Users with 2FA/MFA (Multi-factored auth)
+ * turned on will not be able to use this credential. Please use {@link DeviceCodeCredential} or {@link
+ * InteractiveBrowserCredential} instead, or create a service principal if you want to authenticate silently.
+ */
+public class UsernamePasswordCredential implements TokenCredential {
+}
diff --git a/java/ql/test/stubs/azure-sdk-for-java/com/azure/identity/UsernamePasswordCredentialBuilder.java b/java/ql/test/stubs/azure-sdk-for-java/com/azure/identity/UsernamePasswordCredentialBuilder.java
new file mode 100644
index 00000000000..b6aa411ed84
--- /dev/null
+++ b/java/ql/test/stubs/azure-sdk-for-java/com/azure/identity/UsernamePasswordCredentialBuilder.java
@@ -0,0 +1,74 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+package com.azure.identity;
+
+import com.azure.security.keyvault.secrets.SecretClient;
+
+/**
+ * Fluent credential builder for instantiating a {@link UsernamePasswordCredential}.
+ *
+ * @see UsernamePasswordCredential
+ */
+public class UsernamePasswordCredentialBuilder extends AadCredentialBuilderBasecacheFileLocation() instead of
+ * Gnome keyring on Linux. This is restricted by default.
+ *
+ * @return An updated instance of this builder.
+ */
+ UsernamePasswordCredentialBuilder allowUnencryptedCache() {
+ return null;
+ }
+
+ /**
+ * Enables the shared token cache which is disabled by default. If enabled, the credential will store tokens
+ * in a cache persisted to the machine, protected to the current user, which can be shared by other credentials
+ * and processes.
+ *
+ * @return An updated instance of this builder with if the shared token cache enabled specified.
+ */
+ UsernamePasswordCredentialBuilder enablePersistentCache() {
+ return null;
+ }
+
+ /**
+ * Creates a new {@link UsernamePasswordCredential} with the current configurations.
+ *
+ * @return a {@link UsernamePasswordCredential} with the current configurations.
+ */
+ public UsernamePasswordCredential build() {
+ return null;
+ }
+}
diff --git a/java/ql/test/stubs/azure-sdk-for-java/com/azure/security/keyvault/secrets/SecretClient.java b/java/ql/test/stubs/azure-sdk-for-java/com/azure/security/keyvault/secrets/SecretClient.java
new file mode 100644
index 00000000000..94cdc7d1be7
--- /dev/null
+++ b/java/ql/test/stubs/azure-sdk-for-java/com/azure/security/keyvault/secrets/SecretClient.java
@@ -0,0 +1,155 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+package com.azure.security.keyvault.secrets;
+
+import com.azure.security.keyvault.secrets.models.KeyVaultSecret;
+import com.azure.security.keyvault.secrets.models.SecretProperties;
+
+/**
+ * The SecretClient provides synchronous methods to manage {@link KeyVaultSecret secrets} in the Azure Key Vault. The client
+ * supports creating, retrieving, updating, deleting, purging, backing up, restoring, and listing the {@link KeyVaultSecret
+ * secrets}. The client also supports listing {@link DeletedSecret deleted secrets} for a soft-delete enabled Azure Key
+ * Vault.
+ *
+ * Construct the sync client
+ * {@codesnippet com.azure.security.keyvault.secretclient.sync.construct} + * + * @see SecretClientBuilder + * @see PagedIterable + */ +public final class SecretClient { + + /** + * Gets the vault endpoint url to which service requests are sent to. + * @return the vault endpoint url. + */ + public String getVaultUrl() { + return null; + } + + /** + * Adds a secret to the key vault if it does not exist. If the named secret exists, a new version of the secret is + * created. This operation requires the {@code secrets/set} permission. + * + *The {@link SecretProperties#getExpiresOn() expires}, {@link SecretProperties#getContentType() contentType}, + * and {@link SecretProperties#getNotBefore() notBefore} values in {@code secret} are optional. + * If not specified, {@link SecretProperties#isEnabled() enabled} is set to true by key vault.
+ * + *Code sample
+ *Creates a new secret in the key vault. Prints out the details of the newly created secret returned in the + * response.
+ * {@codesnippet com.azure.security.keyvault.secretclient.setSecret#secret} + * + * @param secret The Secret object containing information about the secret and its properties. The properties + * {@link KeyVaultSecret#getName() secret.name} and {@link KeyVaultSecret#getValue() secret.value} cannot be + * null. + * @return The {@link KeyVaultSecret created secret}. + * @throws NullPointerException if {@code secret} is {@code null}. + * @throws ResourceModifiedException if {@code secret} is malformed. + * @throws HttpResponseException if {@link KeyVaultSecret#getName() name} or {@link KeyVaultSecret#getValue() value} + * is an empty string. + */ + public KeyVaultSecret setSecret(KeyVaultSecret secret) { + return null; + } + + /** + * Adds a secret to the key vault if it does not exist. If the named secret exists, a new version of the secret is + * created. This operation requires the {@code secrets/set} permission. + * + *Code sample
+ *Creates a new secret in the key vault. Prints out the details of the newly created secret returned in the + * response.
+ * {@codesnippet com.azure.security.keyvault.secretclient.setSecret#string-string} + * + * @param name The name of the secret. It is required and cannot be null. + * @param value The value of the secret. It is required and cannot be null. + * @return The {@link KeyVaultSecret created secret}. + * @throws ResourceModifiedException if invalid {@code name} or {@code value} is specified. + * @throws HttpResponseException if {@code name} or {@code value} is empty string. + */ + public KeyVaultSecret setSecret(String name, String value) { + return null; + } + + /** + * Gets the specified secret with specified version from the key vault. This operation requires the + * {@code secrets/get} permission. + * + *Code sample
+ *Gets a specific version of the secret in the key vault. Prints out the details of the returned secret.
+ * {@codesnippet com.azure.security.keyvault.secretclient.getSecret#string-string} + * + * @param name The name of the secret, cannot be null. + * @param version The version of the secret to retrieve. If this is an empty string or null, this call is + * equivalent to calling {@link #getSecret(String)}, with the latest version being retrieved. + * @return The requested {@link KeyVaultSecret secret}. + * @throws ResourceNotFoundException when a secret with {@code name} and {@code version} doesn't exist in the + * key vault. + * @throws HttpResponseException if {@code name} or {@code version} is empty string. + */ + public KeyVaultSecret getSecret(String name, String version) { + return null; + } + + /** + * Gets the latest version of the specified secret from the key vault. + * This operation requires the {@code secrets/get} permission. + * + *Code sample
+ *Gets the latest version of the secret in the key vault. Prints out the details of the returned secret.
+ * {@codesnippet com.azure.security.keyvault.secretclient.getSecret#string} + * + * @param name The name of the secret. + * @return The requested {@link KeyVaultSecret}. + * @throws ResourceNotFoundException when a secret with {@code name} doesn't exist in the key vault. + * @throws HttpResponseException if {@code name} is empty string. + */ + public KeyVaultSecret getSecret(String name) { + return null; + } + + /** + * Updates the attributes associated with the secret. The value of the secret in the key vault cannot be changed. + * Only attributes populated in {@code secretProperties} are changed. Attributes not specified in the request are + * not changed. This operation requires the {@code secrets/set} permission. + * + *The {@code secret} is required and its fields {@link SecretProperties#getName() name} and + * {@link SecretProperties#getVersion() version} cannot be null.
+ * + *Code sample
+ *Gets the latest version of the secret, changes its expiry time, and the updates the secret in the key + * vault.
+ * {@codesnippet com.azure.security.keyvault.secretclient.updateSecretProperties#secretProperties} + * + * @param secretProperties The {@link SecretProperties secret properties} object with updated properties. + * @return The {@link SecretProperties updated secret}. + * @throws NullPointerException if {@code secret} is {@code null}. + * @throws ResourceNotFoundException when a secret with {@link SecretProperties#getName() name} and {@link + * SecretProperties#getVersion() version} doesn't exist in the key vault. + * @throws HttpResponseException if {@link SecretProperties#getName() name} or {@link SecretProperties#getVersion() version} is + * empty string. + */ + public SecretProperties updateSecretProperties(SecretProperties secretProperties) { + return null; + } + + /** + * Requests a backup of the secret be downloaded to the client. All versions of the secret will be downloaded. + * This operation requires the {@code secrets/backup} permission. + * + *Code sample
+ *Backs up the secret from the key vault and prints out the length of the secret's backup byte array returned in + * the response
+ * {@codesnippet com.azure.security.keyvault.secretclient.backupSecret#string} + * + * @param name The name of the secret. + * @return A {@link Response} whose {@link Response#getValue() value} contains the backed up secret blob. + * @throws ResourceNotFoundException when a secret with {@code name} doesn't exist in the key vault. + * @throws HttpResponseException when a secret with {@code name} is empty string. + */ + public byte[] backupSecret(String name) { + return null; + } +} diff --git a/java/ql/test/stubs/azure-sdk-for-java/com/azure/security/keyvault/secrets/SecretClientBuilder.java b/java/ql/test/stubs/azure-sdk-for-java/com/azure/security/keyvault/secrets/SecretClientBuilder.java new file mode 100644 index 00000000000..0a90f44f8dd --- /dev/null +++ b/java/ql/test/stubs/azure-sdk-for-java/com/azure/security/keyvault/secrets/SecretClientBuilder.java @@ -0,0 +1,92 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.security.keyvault.secrets; + +import com.azure.core.credential.TokenCredential; + +/** + * This class provides a fluent builder API to help aid the configuration and instantiation of the {@link + * SecretAsyncClient secret async client} and {@link SecretClient secret client}, + * by calling {@link SecretClientBuilder#buildAsyncClient() buildAsyncClient} and {@link + * SecretClientBuilder#buildClient() buildClient} respectively. + * It constructs an instance of the desired client. + * + *The minimal configuration options required by {@link SecretClientBuilder secretClientBuilder} to build + * {@link SecretAsyncClient} are {@link String vaultUrl} and {@link TokenCredential credential}.
+ * + * {@codesnippet com.azure.security.keyvault.secrets.async.secretclient.construct} + * + *Samples to construct the sync client
+ * {@codesnippet com.azure.security.keyvault.secretclient.sync.construct} + * + *The {@link HttpLogDetailLevel log detail level}, multiple custom {@link HttpLoggingPolicy policies} and custom + * {@link HttpClient http client} can be optionally configured in the {@link SecretClientBuilder}.
+ * + * {@codesnippet com.azure.security.keyvault.secrets.async.secretclient.withhttpclient.instantiation} + * + *Alternatively, custom {@link HttpPipeline http pipeline} with custom {@link HttpPipelinePolicy} policies and + * {@link String vaultUrl} + * can be specified. It provides finer control over the construction of {@link SecretAsyncClient client}
+ * + * {@codesnippet com.azure.security.keyvault.secrets.async.secretclient.pipeline.instantiation} + * + * @see SecretClient + * @see SecretAsyncClient + */ +public final class SecretClientBuilder { + /** + * The constructor with defaults. + */ + public SecretClientBuilder() { + } + + /** + * Creates a {@link SecretClient} based on options set in the builder. + * Every time {@code buildClient()} is called, a new instance of {@link SecretClient} is created. + * + *If {@link SecretClientBuilder#pipeline(HttpPipeline) pipeline} is set, then the {@code pipeline} and + * {@link SecretClientBuilder#vaultUrl(String) serviceEndpoint} are used to create the + * {@link SecretClientBuilder client}. All other builder settings are ignored. If {@code pipeline} is not set, + * then {@link SecretClientBuilder#credential(TokenCredential) key vault credential}, and + * {@link SecretClientBuilder#vaultUrl(String)} key vault url are required to build the {@link SecretClient + * client}.
+ * + * @return A {@link SecretClient} with the options set from the builder. + * + * @throws IllegalStateException If {@link SecretClientBuilder#credential(TokenCredential)} or + * {@link SecretClientBuilder#vaultUrl(String)} have not been set. + */ + public SecretClient buildClient() { + return null; + } + + /** + * Sets the vault URL to send HTTP requests to. + * + * @param vaultUrl The vault url is used as destination on Azure to send requests to. If you have a secret + * identifier, create a new {@link KeyVaultSecretIdentifier} to parse it and obtain the {@code vaultUrl} and + * other information. + * + * @return The updated {@link SecretClientBuilder} object. + * + * @throws IllegalArgumentException If {@code vaultUrl} is null or it cannot be parsed into a valid URL. + * @throws NullPointerException If {@code vaultUrl} is {@code null}. + */ + public SecretClientBuilder vaultUrl(String vaultUrl) { + return null; + } + + /** + * Sets the credential to use when authenticating HTTP requests. + * + * @param credential The credential to use for authenticating HTTP requests. + * + * @return The updated {@link SecretClientBuilder} object. + * + * @throws NullPointerException If {@code credential} is {@code null}. + */ + public SecretClientBuilder credential(TokenCredential credential) { + return null; + } +} diff --git a/java/ql/test/stubs/azure-sdk-for-java/com/azure/security/keyvault/secrets/models/KeyVaultSecret.java b/java/ql/test/stubs/azure-sdk-for-java/com/azure/security/keyvault/secrets/models/KeyVaultSecret.java new file mode 100644 index 00000000000..1f2f252a323 --- /dev/null +++ b/java/ql/test/stubs/azure-sdk-for-java/com/azure/security/keyvault/secrets/models/KeyVaultSecret.java @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.security.keyvault.secrets.models; + +import com.azure.security.keyvault.secrets.SecretClient; + +import java.util.Map; +import java.util.Objects; + +/** + * Secret is the resource consisting of name, value and its attributes specified in {@link SecretProperties}. + * It is managed by Secret Service. + * + * @see SecretClient + * @see SecretAsyncClient + */ +public class KeyVaultSecret { + /** + * Creates an empty instance of the Secret. + */ + KeyVaultSecret() { + } + + /** + * Creates a Secret with {@code name} and {@code value}. + * + * @param name The name of the secret. + * @param value the value of the secret. + */ + public KeyVaultSecret(String name, String value) { + } + + /** + * Get the value of the secret. + * + * @return the secret value + */ + public String getValue() { + return null; + } + + /** + * Get the secret identifier. + * + * @return the secret identifier. + */ + public String getId() { + return null; + } + + /** + * Get the secret name. + * + * @return the secret name. + */ + public String getName() { + return null; + } + + /** + * Get the secret properties + * @return the Secret properties + */ + public SecretProperties getProperties() { + return null; + } + + /** + * Set the secret properties + * @param properties The Secret properties + * @throws NullPointerException if {@code properties} is null. + * @return the updated secret object + */ + public KeyVaultSecret setProperties(SecretProperties properties) { + return null; + } +} diff --git a/java/ql/test/stubs/azure-sdk-for-java/com/azure/security/keyvault/secrets/models/SecretProperties.java b/java/ql/test/stubs/azure-sdk-for-java/com/azure/security/keyvault/secrets/models/SecretProperties.java new file mode 100644 index 00000000000..750db3ff177 --- /dev/null +++ b/java/ql/test/stubs/azure-sdk-for-java/com/azure/security/keyvault/secrets/models/SecretProperties.java @@ -0,0 +1,145 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.security.keyvault.secrets.models; + +import java.util.Map; + +import com.azure.security.keyvault.secrets.SecretClient; + +/** + * SecretProperties is the resource containing all the properties of the secret except its value. + * It is managed by the Secret Service. + * + * @see SecretClient + * @see SecretAsyncClient + */ +public class SecretProperties { + SecretProperties(String secretName) { + } + + /** + * Creates empty instance of SecretProperties. + */ + public SecretProperties() { } + + /** + * Get the secret name. + * + * @return the name of the secret. + */ + public String getName() { + return null; + } + + /** + * Get the recovery level of the secret. + + * @return the recoveryLevel of the secret. + */ + public String getRecoveryLevel() { + return null; + } + + /** + * Get the enabled value. + * + * @return the enabled value + */ + public Boolean isEnabled() { + return false; + } + + /** + * Set the enabled value. + * + * @param enabled The enabled value to set + * @throws NullPointerException if {@code enabled} is null. + * @return the SecretProperties object itself. + */ + public SecretProperties setEnabled(Boolean enabled) { + return null; + } + + /** + * Get the secret identifier. + * + * @return the secret identifier. + */ + public String getId() { + return null; + } + + /** + * Get the content type. + * + * @return the content type. + */ + public String getContentType() { + return null; + } + + /** + * Set the contentType. + * + * @param contentType The contentType to set + * @return the updated SecretProperties object itself. + */ + public SecretProperties setContentType(String contentType) { + return null; + } + + /** + * Get the tags associated with the secret. + * + * @return the value of the tags. + */ + public Map- The following code example connects to AWS using a hard-coded access key ID and secret key: -
- -- Instead, the access key ID and secret key could be supplied through environment variables, - which can be set externally without hard-coding credentials in the source code. -
- -- The following code example connects to Azure using a hard-coded user name and password or client secret: -
- -- Instead, the username and password or client secret could be supplied through environment variables, - which can be set externally without hard-coding credentials in the source code. -