-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from andrerod/multimodule_5
Add management module
- Loading branch information
Showing
460 changed files
with
99,463 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
microsoft-azure-api-core/src/main/java/com/microsoft/windowsazure/CloudCredentials.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* Copyright Microsoft Corporation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.microsoft.windowsazure; | ||
|
||
import org.apache.http.impl.client.CloseableHttpClient; | ||
|
||
public abstract class CloudCredentials { | ||
public abstract CloseableHttpClient initializeClient(); | ||
} |
80 changes: 80 additions & 0 deletions
80
...core/src/main/java/com/microsoft/windowsazure/management/CertificateCloudCredentials.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/** | ||
* Copyright Microsoft Corporation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.microsoft.windowsazure.management; | ||
|
||
import java.io.IOException; | ||
import java.security.GeneralSecurityException; | ||
import javax.net.ssl.SSLContext; | ||
import org.apache.http.conn.ssl.SSLConnectionSocketFactory; | ||
import org.apache.http.impl.client.CloseableHttpClient; | ||
import org.apache.http.impl.client.HttpClients; | ||
|
||
public class CertificateCloudCredentials extends SubscriptionCloudCredentials { | ||
private String _subscriptionId; | ||
private KeyStoreCredential _keyStoreCredential; | ||
|
||
public CertificateCloudCredentials(String subscriptionId) | ||
{ | ||
this._subscriptionId = subscriptionId; | ||
} | ||
|
||
public CertificateCloudCredentials(String subscriptionId, KeyStoreCredential keyStoreCredential) | ||
{ | ||
this._subscriptionId = subscriptionId; | ||
this._keyStoreCredential = keyStoreCredential; | ||
} | ||
|
||
@Override | ||
public String getSubscriptionId() | ||
{ | ||
return _subscriptionId; | ||
} | ||
|
||
public void setSubscriptionId(String subscriptionId) | ||
{ | ||
_subscriptionId = subscriptionId; | ||
} | ||
|
||
public KeyStoreCredential getKeyStoreCredential() | ||
{ | ||
return _keyStoreCredential; | ||
} | ||
|
||
public void setKeyStoreCredential(KeyStoreCredential keyStoreCredential) | ||
{ | ||
_keyStoreCredential = keyStoreCredential; | ||
} | ||
|
||
@Override | ||
public CloseableHttpClient initializeClient() | ||
{ | ||
try { | ||
SSLContext sslcontext = SSLContextFactory.create(this.getKeyStoreCredential()); | ||
|
||
return HttpClients.custom() | ||
.setSSLSocketFactory(new SSLConnectionSocketFactory(sslcontext)) | ||
.build(); | ||
} | ||
catch (IOException e) | ||
{ | ||
return null; | ||
} | ||
catch (GeneralSecurityException e) | ||
{ | ||
return null; | ||
} | ||
} | ||
} |
83 changes: 83 additions & 0 deletions
83
...zure-api-core/src/main/java/com/microsoft/windowsazure/management/KeyStoreCredential.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/** | ||
* Copyright Microsoft Corporation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.microsoft.windowsazure.management; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* The Class KeyStoreCredential. | ||
*/ | ||
public class KeyStoreCredential { | ||
|
||
/** The password of the keystore. */ | ||
private final String keystorePassword; | ||
|
||
/** The key store path. */ | ||
private final String keyStorePath; | ||
|
||
/** The key store type. */ | ||
private final KeyStoreType keyStoreType; | ||
|
||
/** | ||
* Creates a <code>KeyStoreCredential</code> instance from a keyStore. | ||
* | ||
* @param keyStorePath | ||
* the path of the keystore. | ||
* @param keyStorePassword | ||
* the password for the keystore. | ||
* @param keyStoreType | ||
* the type of the keyStore. | ||
* @throws IOException | ||
* when a I/O exception has occurred. | ||
*/ | ||
public KeyStoreCredential(String keyStorePath, String keyStorePassword, KeyStoreType keyStoreType) | ||
throws IOException { | ||
this.keystorePassword = keyStorePassword; | ||
this.keyStorePath = keyStorePath; | ||
this.keyStoreType = keyStoreType; | ||
} | ||
|
||
public KeyStoreCredential(String keyStorePath, String keyStorePassword) throws IOException { | ||
this(keyStorePath, keyStorePassword, KeyStoreType.jks); | ||
} | ||
|
||
/** | ||
* Gets the type of the key store. | ||
* | ||
* @return A <code>KeyStoreType</code> representing the type of the key store. | ||
*/ | ||
public KeyStoreType getKeyStoreType() { | ||
return keyStoreType; | ||
} | ||
|
||
/** | ||
* Gets the keystore password. | ||
* | ||
* @return A <code>String</code> instance representing the password of the keystore. | ||
*/ | ||
public String getKeystorePassword() { | ||
return keystorePassword; | ||
} | ||
|
||
/** | ||
* Gets the key store path. | ||
* | ||
* @return the key store path | ||
*/ | ||
public String getKeyStorePath() { | ||
return this.keyStorePath; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...soft-azure-api-core/src/main/java/com/microsoft/windowsazure/management/KeyStoreType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* Copyright Microsoft Corporation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.microsoft.windowsazure.management; | ||
|
||
/** | ||
* The Enum representing the type of the KeyStore. | ||
*/ | ||
public enum KeyStoreType { | ||
|
||
/** The jceks. */ | ||
jceks, | ||
/** The jks. */ | ||
jks, | ||
/** The pkcs12. */ | ||
pkcs12 | ||
} |
108 changes: 108 additions & 0 deletions
108
...api-core/src/main/java/com/microsoft/windowsazure/management/ManagementConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/** | ||
* Copyright Microsoft Corporation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.microsoft.windowsazure.management; | ||
|
||
import com.microsoft.windowsazure.services.core.Configuration; | ||
|
||
/** | ||
* Provides functionality to create a service management configuration. | ||
* | ||
*/ | ||
public class ManagementConfiguration { | ||
|
||
/** | ||
* Defines the path of the keystore. | ||
* | ||
*/ | ||
public final static String KEYSTORE_PATH = "AZURE_MANAGEMENT_KEYSTORE_PATH"; | ||
|
||
/** | ||
* Defines the password of the keystore. | ||
* | ||
*/ | ||
public final static String KEYSTORE_PASSWORD = "AZURE_MANAGEMENT_KEYSTORE_PASSWORD"; | ||
|
||
/** | ||
* Defines the type of the keystore. | ||
*/ | ||
public static final String KEYSTORE_TYPE = "AZURE_MANAGEMENT_KEYSTORE_TYPE"; | ||
|
||
/** | ||
* Defines the URI of service management. | ||
* | ||
*/ | ||
public final static String URI = "AZURE_MANAGEMENT_URI"; | ||
|
||
/** | ||
* Defines the subscription ID of the Windows Azure account. | ||
*/ | ||
public static final String SUBSCRIPTION_ID = "AZURE_SUBSCRIPTION_ID"; | ||
|
||
public static final String SUBSCRIPTION_CLOUD_CREDENTIALS = "AZURE_SUBSCRIPTION_CLOUD_CREDENTIALS"; | ||
|
||
/** | ||
* Creates a service management configuration using specified URI, and subscription ID. | ||
* | ||
* @param uri | ||
* A <code>String</code> object that represents the root URI of the service management service. | ||
* @param subscriptionId | ||
* A <code>String</code> object that represents the subscription ID. | ||
* @return the configuration | ||
* A <code>Configuration</code> object that can be used when creating an instance of the | ||
* <code>ManagementContract</code> class. | ||
*/ | ||
public static Configuration configure(String uri, String subscriptionId) { | ||
return configure(null, Configuration.getInstance(), uri, subscriptionId, null, null); | ||
} | ||
|
||
/** | ||
* Creates a service management configuration with specified parameters. | ||
* | ||
* @param profile | ||
* A <code>String</code> object that represents the profile. | ||
* @param configuration | ||
* A previously instantiated <code>Configuration</code> object. | ||
* @param uri | ||
* A <code>String</code> object that represents the URI of the service management service. | ||
* @param subscriptionId | ||
* A <code>String</code> object that represents the subscription ID. | ||
* @param keyStoreLocation | ||
* the key store location | ||
* @param keyStorePassword | ||
* A <code>String</code> object that represents the password of the keystore. | ||
* @return A <code>Configuration</code> object that can be used when creating an instance of the | ||
* <code>ManagementContract</code> class. | ||
*/ | ||
public static Configuration configure(String profile, Configuration configuration, String uri, | ||
String subscriptionId, String keyStoreLocation, String keyStorePassword) { | ||
|
||
if (profile == null) { | ||
profile = ""; | ||
} | ||
else if (profile.length() != 0 && !profile.endsWith(".")) { | ||
profile = profile + "."; | ||
} | ||
|
||
configuration.setProperty(profile + URI, "https://" + uri); | ||
configuration.setProperty(profile + SUBSCRIPTION_ID, subscriptionId); | ||
configuration.setProperty(profile + KEYSTORE_PATH, keyStoreLocation); | ||
configuration.setProperty(profile + KEYSTORE_PASSWORD, keyStorePassword); | ||
|
||
configuration.setProperty(profile + SUBSCRIPTION_CLOUD_CREDENTIALS, | ||
new CertificateCloudCredentials(subscriptionId)); | ||
|
||
return configuration; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...azure-api-core/src/main/java/com/microsoft/windowsazure/management/OperationResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* Copyright Microsoft Corporation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.microsoft.windowsazure.management; | ||
|
||
public class OperationResponse { | ||
private int _httpStatusCode; | ||
|
||
/** | ||
* Gets the HTTP status code for the request. | ||
*/ | ||
public int getStatusCode() { return this._httpStatusCode; } | ||
|
||
/** | ||
* Sets the HTTP status code for the request. | ||
*/ | ||
public void setStatusCode(int httpStatusCode) { this._httpStatusCode = httpStatusCode; } | ||
|
||
private String _requestId; | ||
|
||
/** | ||
* Gets the request identifier. | ||
*/ | ||
public String getRequestId() { return this._requestId; } | ||
|
||
/** | ||
* Sets the request identifier. | ||
*/ | ||
public void setRequestId(String requestId) { this._requestId = requestId; } | ||
} |
Oops, something went wrong.