Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add module-info to jca and jca test module and change package name of jca test module #22041

Merged
merged 8 commits into from
Jun 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
/**
* The REST client specific to getting an access token for Azure REST APIs.
*/
class AuthClient extends DelegateRestClient {
public class AuthClient extends DelegateRestClient {

/**
* Stores the Client ID fragment.
Expand Down Expand Up @@ -63,7 +63,7 @@ class AuthClient extends DelegateRestClient {
* The constructor creates a default RestClient.
* </p>
*/
AuthClient() {
public AuthClient() {
super(RestClientFactory.createClient());
}

Expand Down Expand Up @@ -91,13 +91,14 @@ public String getAccessToken(String resource, String identity) {
*
* @param resource the resource.
* @param tenantId the tenant ID.
* @param aadAuthenticationUrl the AAD authentication url
* @param clientId the client ID.
* @param clientSecret the client secret.
* @return the authorization token.
*/
public String getAccessToken(String resource, String aadAuthenticationUrl,
String tenantId, String clientId, String clientSecret) {

LOGGER.entering("AuthClient", "getAccessToken", new Object[]{
resource, tenantId, clientId, clientSecret});
LOGGER.info("Getting access token using client ID / client secret");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
/**
* The REST client specific to Azure Key Vault.
*/
class KeyVaultClient extends DelegateRestClient {
public class KeyVaultClient extends DelegateRestClient {

/**
* Stores the logger.
Expand Down Expand Up @@ -118,7 +118,7 @@ class KeyVaultClient extends DelegateRestClient {
* @param clientId the client ID.
* @param clientSecret the client secret.
*/
KeyVaultClient(final String keyVaultUri, final String tenantId, final String clientId, final String clientSecret) {
public KeyVaultClient(final String keyVaultUri, final String tenantId, final String clientId, final String clientSecret) {
this(keyVaultUri, tenantId, clientId, clientSecret, null);
}

Expand Down Expand Up @@ -186,7 +186,7 @@ private String getAccessToken() {
*
* @return the list of aliases.
*/
List<String> getAliases() {
public List<String> getAliases() {
ArrayList<String> result = new ArrayList<>();
HashMap<String, String> headers = new HashMap<>();
headers.put("Authorization", "Bearer " + getAccessToken());
Expand Down Expand Up @@ -239,7 +239,7 @@ private CertificateBundle getCertificateBundle(String alias) {
* @param alias the alias.
* @return the certificate, or null if not found.
*/
Certificate getCertificate(String alias) {
public Certificate getCertificate(String alias) {
LOGGER.entering("KeyVaultClient", "getCertificate", alias);
LOGGER.log(INFO, "Getting certificate for alias: {0}", alias);
X509Certificate certificate = null;
Expand Down Expand Up @@ -268,7 +268,7 @@ Certificate getCertificate(String alias) {
* @param password the password.
* @return the key.
*/
Key getKey(String alias, char[] password) {
public Key getKey(String alias, char[] password) {
LOGGER.entering("KeyVaultClient", "getKey", new Object[]{alias, password});
LOGGER.log(INFO, "Getting key for alias: {0}", alias);
Key key = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/**
* The REST client API.
*/
interface RestClient {
public interface RestClient {

/**
* Issue a GET request.
Expand All @@ -24,6 +24,7 @@ interface RestClient {
*
* @param url the URL.
* @param body the request body.
* @param contentType the content type
* @return the response body as a string.
*/
String post(String url, String body, String contentType);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

/**
* This module info is only for development purpose. Maven shade plugin will ignore this file. The one actually deployed is src/main/module-info.java
*/
module azure.security.keyvault.jca {
requires java.logging;
requires org.apache.httpcomponents.httpclient;
requires org.apache.httpcomponents.httpcore;
requires com.fasterxml.jackson.databind;

exports com.azure.security.keyvault.jca;
exports com.azure.security.keyvault.jca.model;
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.


/**
* This module info will be deployed instead of the one under src/main/java.
*/
module azure.security.keyvault.jca {
requires java.logging;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.security.keyvault.jca.test;

import com.azure.security.keyvault.jca.KeyVaultJcaProvider;
import com.azure.security.keyvault.jca.model.CertificateBundle;

public class TestModularization {
/**
* Simply test compiling ok.
*/
void testCompile() {
KeyVaultJcaProvider keyVaultJcaProvider = new KeyVaultJcaProvider();
CertificateBundle certificateBundle = new CertificateBundle();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

/**
* This is for testing the modularization of module azure.security.keyvault.jca
*/
module azure.security.keyvault.jca.test {
requires azure.security.keyvault.jca;
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.security.keyvault.jca;
package com.azure.security.keyvault.jca.test;

import com.azure.security.keyvault.jca.AuthClient;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.security.keyvault.jca;
package com.azure.security.keyvault.jca.test;

import com.azure.security.keyvault.jca.JreCertificates;
import com.azure.security.keyvault.jca.KeyVaultJcaProvider;
import org.apache.http.HttpResponse;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpGet;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.security.keyvault.jca;
package com.azure.security.keyvault.jca.test;

import com.azure.security.keyvault.jca.KeyVaultCertificates;
import com.azure.security.keyvault.jca.KeyVaultJcaProvider;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
Expand All @@ -16,7 +18,6 @@
import java.security.cert.X509Certificate;
import java.util.Base64;

import static com.azure.security.keyvault.jca.PropertyConvertorUtils.SYSTEM_PROPERTIES;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand Down Expand Up @@ -55,7 +56,7 @@ public class KeyVaultCertificatesTest {

@BeforeAll
public static void setEnvironmentProperty() {
PropertyConvertorUtils.putEnvironmentPropertyToSystemProperty(SYSTEM_PROPERTIES);
PropertyConvertorUtils.putEnvironmentPropertyToSystemProperty(PropertyConvertorUtils.SYSTEM_PROPERTIES);
KeyVaultJcaProvider provider = new KeyVaultJcaProvider();
Security.addProvider(provider);
certificateName = System.getenv("AZURE_KEYVAULT_CERTIFICATE_NAME");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.security.keyvault.jca;
package com.azure.security.keyvault.jca.test;

import com.azure.security.keyvault.jca.KeyVaultClient;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.security.keyvault.jca;
package com.azure.security.keyvault.jca.test;

import com.azure.security.keyvault.jca.KeyVaultJcaProvider;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;

import java.security.KeyStore;
import java.security.Security;

import static com.azure.security.keyvault.jca.PropertyConvertorUtils.SYSTEM_PROPERTIES;
import static com.azure.security.keyvault.jca.test.PropertyConvertorUtils.SYSTEM_PROPERTIES;
import static org.junit.jupiter.api.Assertions.assertNotNull;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.security.keyvault.jca;
package com.azure.security.keyvault.jca.test;

import com.azure.security.keyvault.jca.KeyVaultJcaProvider;
import com.azure.security.keyvault.jca.KeyVaultKeyManager;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
Expand All @@ -14,7 +16,7 @@
import java.security.Security;
import java.security.cert.CertificateException;

import static com.azure.security.keyvault.jca.PropertyConvertorUtils.SYSTEM_PROPERTIES;
import static com.azure.security.keyvault.jca.test.PropertyConvertorUtils.SYSTEM_PROPERTIES;
import static org.junit.jupiter.api.Assertions.assertNotNull;

@EnabledIfEnvironmentVariable(named = "AZURE_KEYVAULT_CERTIFICATE_NAME", matches = "myalias")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.security.keyvault.jca;
package com.azure.security.keyvault.jca.test;

import com.azure.security.keyvault.jca.KeyVaultJcaProvider;
import com.azure.security.keyvault.jca.KeyVaultKeyStore;
import com.azure.security.keyvault.jca.KeyVaultLoadStoreParameter;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
Expand All @@ -17,7 +20,7 @@
import java.security.cert.X509Certificate;
import java.util.Base64;

import static com.azure.security.keyvault.jca.PropertyConvertorUtils.SYSTEM_PROPERTIES;
import static com.azure.security.keyvault.jca.test.PropertyConvertorUtils.SYSTEM_PROPERTIES;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.security.keyvault.jca;
package com.azure.security.keyvault.jca.test;

import com.azure.security.keyvault.jca.KeyVaultLoadStoreParameter;

import java.io.IOException;
import java.security.KeyStore;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.security.keyvault.jca;
package com.azure.security.keyvault.jca.test;

import com.azure.security.keyvault.jca.KeyVaultJcaProvider;
import com.azure.security.keyvault.jca.KeyVaultTrustManagerFactoryProvider;
import org.apache.http.HttpResponse;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpGet;
Expand Down Expand Up @@ -33,7 +35,7 @@
import java.security.cert.X509Certificate;
import java.util.Map;

import static com.azure.security.keyvault.jca.PropertyConvertorUtils.SYSTEM_PROPERTIES;
import static com.azure.security.keyvault.jca.test.PropertyConvertorUtils.SYSTEM_PROPERTIES;
import static org.junit.jupiter.api.Assertions.assertEquals;

/**
Expand Down