com.microsoft.azure.keyvault.authentication.KeyVaultCredentials Java Examples

The following examples show how to use com.microsoft.azure.keyvault.authentication.KeyVaultCredentials. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KeyVault.java    From remote-monitoring-services-java with MIT License 6 votes vote down vote up
/**
 * Creates a new KeyVaultCredential based on the access token obtained.
 *
 * @return
 */
private ServiceClientCredentials createCredentials() {
    return new KeyVaultCredentials() {

        //Callback that supplies the token type and access token on request.
        @Override
        public String doAuthenticate(String authorization, String resource, String scope) {

            AuthenticationResult authResult;
            try {
                authResult = getAccessToken(authorization, resource);
                return authResult.getAccessToken();
            } catch (Exception e) {
                // TODO: Add logging
                log.error("Failed to get the saccess token for accessing the keyvault.", e);
                // e.printStackTrace();
            }
            return "";
        }

    };
}
 
Example #2
Source File: KeyVault.java    From remote-monitoring-services-java with MIT License 6 votes vote down vote up
/**
 * Creates a new KeyVaultCredential based on the access token obtained.
 *
 * @return
 */
private ServiceClientCredentials createCredentials() {
    return new KeyVaultCredentials() {

        //Callback that supplies the token type and access token on request.
        @Override
        public String doAuthenticate(String authorization, String resource, String scope) {

            AuthenticationResult authResult;
            try {
                authResult = getAccessToken(authorization, resource);
                return authResult.getAccessToken();
            } catch (Exception e) {
                log.error("Failed to get authentication token for key vault.",e);
                // e.printStackTrace();
            }
            return "";
        }

    };
}
 
Example #3
Source File: KeyVault.java    From remote-monitoring-services-java with MIT License 6 votes vote down vote up
/**
 * Creates a new KeyVaultCredential based on the access token obtained.
 *
 * @return
 */
private ServiceClientCredentials createCredentials() {
    return new KeyVaultCredentials() {

        //Callback that supplies the token type and access token on request.
        @Override
        public String doAuthenticate(String authorization, String resource, String scope) {

            AuthenticationResult authResult;
            try {
                authResult = getAccessToken(authorization, resource);
                return authResult.getAccessToken();
            } catch (Exception e) {
                log.error("Failed to get authentication token for key vault.",e);
                // e.printStackTrace();
            }
            return "";
        }

    };
}
 
Example #4
Source File: KeyVault.java    From remote-monitoring-services-java with MIT License 6 votes vote down vote up
/**
 * Creates a new KeyVaultCredential based on the access token obtained.
 *
 * @return
 */
private ServiceClientCredentials createCredentials() {
    return new KeyVaultCredentials() {

        //Callback that supplies the token type and access token on request.
        @Override
        public String doAuthenticate(String authorization, String resource, String scope) {

            AuthenticationResult authResult;
            try {
                authResult = getAccessToken(authorization, resource);
                return authResult.getAccessToken();
            } catch (Exception e) {
                log.error("Failed to get authentication token for key vault.",e);
                // e.printStackTrace();
            }
            return "";
        }

    };
}
 
Example #5
Source File: EcKeyIntegrationTests.java    From azure-keyvault-java with MIT License 6 votes vote down vote up
private static ServiceClientCredentials createTestCredentials() throws Exception {
    return new KeyVaultCredentials() {

        @Override
        public String doAuthenticate(String authorization, String resource, String scope) {
            try {
                if (isRecordMode()) {
                    AuthenticationResult authResult = getAccessToken(authorization, resource);
                    return authResult.getAccessToken();
                } else {
                    return "";
                }
            } catch (Exception ex) {
                throw new RuntimeException(ex);
            }
        }
    };
}
 
Example #6
Source File: KeyVaultClientIntegrationTestBase.java    From azure-keyvault-java with MIT License 6 votes vote down vote up
private static ServiceClientCredentials createTestCredentials() throws Exception {
	return new KeyVaultCredentials() {

		@Override
		public String doAuthenticate(String authorization, String resource, String scope) {
			try {

				if (isRecordMode()) {
					AuthenticationResult authResult = getAccessToken(authorization, resource);
					return authResult.getAccessToken();
				} else {
					return "";
				}

			} catch (Exception ex) {
				throw new RuntimeException(ex);
			}
		}
	};
}
 
Example #7
Source File: ITManagedStorageAccountKey.java    From azure-keyvault-java with MIT License 6 votes vote down vote up
private static ServiceClientCredentials createTestCredentials() throws Exception {
    return new KeyVaultCredentials() {

        @Override
        public String doAuthenticate(String authorization, String resource, String scope) {
            try {

                if (isRecordMode()) {
                    AuthenticationResult authResult = getAccessToken(authorization, resource);
                    return authResult.getAccessToken();
                } else {
                    return "";
                }

            } catch (Exception ex) {
                throw new RuntimeException(ex);
            }
        }
    };
}
 
Example #8
Source File: KeyVaultClientIntegrationTestBase.java    From azure-keyvault-java with MIT License 6 votes vote down vote up
private static ServiceClientCredentials createTestCredentials() throws Exception {
	return new KeyVaultCredentials() {

		@Override
		public String doAuthenticate(String authorization, String resource, String scope) {
			try {

				if (isRecordMode()) {
					AuthenticationResult authResult = getAccessToken(authorization, resource);
					return authResult.getAccessToken();
				} else {
					return "";
				}

			} catch (Exception ex) {
				throw new RuntimeException(ex);
			}
		}
	};
}
 
Example #9
Source File: AzureKms.java    From sfs with Apache License 2.0 6 votes vote down vote up
private CloudCredentials createCredentials(VertxContext<Server> vertxContext) throws Exception {
    return new KeyVaultCredentials() {

        @Override
        public Header doAuthenticate(ServiceRequestContext request, Map<String, String> challenge) {
            try {
                String authorization = challenge.get("authorization");
                String resource = challenge.get("resource");
                AuthenticationResult authResult = getAccessToken(vertxContext, accessKeyId, secretKey, authorization, resource);
                return new BasicHeader("Authorization", authResult.getAccessTokenType() + " " + authResult.getAccessToken());
            } catch (Exception ex) {
                throw new RuntimeException(ex);
            }
        }
    };
}