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

Npatilsen/dps cert march #1687

Draft
wants to merge 16 commits into
base: preview
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,13 @@ public void individualEnrollmentWithECCCertificates() throws Exception
private void basicRegistrationFlow(EnrollmentType enrollmentType) throws Exception
{
testInstance.securityProvider = getSecurityProviderInstance(enrollmentType);
registerDevice(testInstance.protocol, testInstance.securityProvider, provisioningServiceGlobalEndpoint, false, null, null, null);
registerDevice(testInstance.protocol, testInstance.securityProvider, provisioningServiceGlobalEndpoint, false, null, false, null);
}

private void basicRegistrationFlowUsingOperationalClientCertificate(EnrollmentType enrollmentType) throws Exception
{
testInstance.securityProvider = getSecurityProviderInstance(enrollmentType);
registerDevice(testInstance.protocol, testInstance.securityProvider, provisioningServiceGlobalEndpoint, false, null, true, null);
}

private void enrollmentWithInvalidRemoteServerCertificateFails(EnrollmentType enrollmentType) throws Exception
Expand All @@ -128,7 +134,7 @@ private void enrollmentWithInvalidRemoteServerCertificateFails(EnrollmentType en
// Register identity
try
{
registerDevice(testInstance.protocol, testInstance.securityProvider, provisioningServiceGlobalEndpointWithInvalidCert, false, null, null, null);
registerDevice(testInstance.protocol, testInstance.securityProvider, provisioningServiceGlobalEndpointWithInvalidCert, false, null, false, null);
}
catch (Exception | AssertionError e)
{
Expand Down Expand Up @@ -164,4 +170,15 @@ else if (testInstance.protocol == MQTT || testInstance.protocol == MQTT_WS)

assertTrue("Expected an exception to be thrown due to invalid server certificates", expectedExceptionEncountered);
}

// TODO -- move these to ProvisioningCommon.java?
private String GenerateClientCertKeyPairAndCsr(String registrationId)
{
return "";
}

private void CleanupCerts()
{
return;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -315,18 +315,18 @@ public void waitForRegistrationCallback(ProvisioningStatus provisioningStatus) t
assertFalse(CorrelationDetailsLoggingAssert.buildExceptionMessageDpsIndividualOrGroup("Expected uri", getHostName(provisioningServiceConnectionString), testInstance.groupId, testInstance.registrationId), testInstance.provisionedIotHubUri.isEmpty());
}

public ProvisioningStatus registerDevice(ProvisioningDeviceClientTransportProtocol protocol, SecurityProvider securityProvider, String globalEndpoint, boolean withRetry, String jsonPayload, String... expectedIotHubsToProvisionTo) throws Exception
public ProvisioningStatus registerDevice(ProvisioningDeviceClientTransportProtocol protocol, SecurityProvider securityProvider, String globalEndpoint, boolean withRetry, String jsonPayload, boolean connectUsingOperationalCertificate, String... expectedIotHubsToProvisionTo) throws Exception
{
ArrayList<String> expectedHubsToProvisionTo = new ArrayList<>(Arrays.asList(expectedIotHubsToProvisionTo));
return registerDevice(protocol, securityProvider, globalEndpoint, withRetry, expectedHubsToProvisionTo, jsonPayload);
return registerDevice(protocol, securityProvider, globalEndpoint, withRetry, expectedHubsToProvisionTo, jsonPayload, connectUsingOperationalCertificate);
}

public ProvisioningStatus registerDevice(ProvisioningDeviceClientTransportProtocol protocol, SecurityProvider securityProvider, String globalEndpoint, boolean withRetry, List<String> expectedIotHubsToProvisionTo) throws Exception
public ProvisioningStatus registerDevice(ProvisioningDeviceClientTransportProtocol protocol, SecurityProvider securityProvider, String globalEndpoint, boolean withRetry, List<String> expectedIotHubsToProvisionTo, boolean connectUsingOperationalCertificate) throws Exception
{
return registerDevice(protocol, securityProvider, globalEndpoint, withRetry, expectedIotHubsToProvisionTo, null);
return registerDevice(protocol, securityProvider, globalEndpoint, withRetry, expectedIotHubsToProvisionTo, connectUsingOperationalCertificate);
}

public ProvisioningStatus registerDevice(ProvisioningDeviceClientTransportProtocol protocol, SecurityProvider securityProvider, String globalEndpoint, boolean withRetry, List<String> expectedIotHubsToProvisionTo, String jsonPayload) throws Exception
public ProvisioningStatus registerDevice(ProvisioningDeviceClientTransportProtocol protocol, SecurityProvider securityProvider, String globalEndpoint, boolean withRetry, List<String> expectedIotHubsToProvisionTo, String jsonPayload, boolean connectUsingOperationalCertificate) throws Exception
{
ProvisioningStatus provisioningStatus = null;
long startTime = System.currentTimeMillis();
Expand Down
1 change: 1 addition & 0 deletions provisioning/provisioning-device-client-samples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
<module>provisioning-symmetrickey-individual-sample</module>
<module>provisioning-tpm-sample</module>
<module>provisioning-X509-sample</module>
<module>provisioning-certificate-issuance-sample</module>
</modules>
<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<!-- Copyright (c) Microsoft. All rights reserved. --><!-- Licensed under the MIT license. See LICENSE file in the project root for full license information. -->
<project>
<parent>
<groupId>com.microsoft.azure.sdk.iot.provisioning.samples</groupId>
<artifactId>provisioning-device-client-samples</artifactId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>provisioning-certificate-issuance-sample</artifactId>
<version>1.0.0</version>
<name>Provisioning Certificate Issuance Sample for Device Client</name>
<developers>
<developer>
<id>microsoft</id>
<name>Microsoft</name>
</developer>
</developers>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.microsoft.azure.sdk.iot.provisioning.security</groupId>
<artifactId>${x509-provider-artifact-id}</artifactId>
<version>${x509-provider-version}</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure.sdk.iot.provisioning</groupId>
<artifactId>${provisioning-device-client-artifact-id}</artifactId>
<version>${provisioning-device-client-version}</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure.sdk.iot</groupId>
<artifactId>${iot-device-client-artifact-id}</artifactId>
<version>${iot-device-client-version}</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcmail-jdk15on</artifactId>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>samples.com.microsoft.azure.sdk.iot.ProvisioningCertificateIssuanceSample</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>with-deps</shadedClassifierName>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Loading