-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: shweta <[email protected]>
- Loading branch information
1 parent
15147a4
commit d0001e5
Showing
20 changed files
with
161 additions
and
4 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file renamed
BIN
+25.8 MB
...reautomation-client-sdk-3.6.0-javadoc.jar → ...reautomation-client-sdk-3.7.0-javadoc.jar
Binary file not shown.
Binary file renamed
BIN
+12.4 MB
lib/vsphereautomation-client-sdk-3.6.0.jar → lib/vsphereautomation-client-sdk-3.7.0.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
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
62 changes: 62 additions & 0 deletions
62
...main/java/vmware/samples/vcenter/certificatemanagement/vcenter/GetSigningCertificate.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,62 @@ | ||
/* | ||
* ******************************************************* | ||
* Copyright VMware, Inc. 2021. All Rights Reserved. | ||
* SPDX-License-Identifier: MIT | ||
* ******************************************************* | ||
* | ||
* DISCLAIMER. THIS PROGRAM IS PROVIDED TO YOU "AS IS" WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, WHETHER ORAL OR WRITTEN, | ||
* EXPRESS OR IMPLIED. THE AUTHOR SPECIFICALLY DISCLAIMS ANY IMPLIED | ||
* WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, | ||
* NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. | ||
*/ | ||
package vmware.samples.vcenter.certificatemanagement.vcenter; | ||
|
||
import com.vmware.vcenter.certificate_management.vcenter.SigningCertificate; | ||
import com.vmware.vcenter.certificate_management.vcenter.SigningCertificateTypes.Info; | ||
|
||
import java.util.ArrayList; | ||
|
||
import org.apache.commons.cli.Option; | ||
|
||
import vmware.samples.common.SamplesAbstractBase; | ||
|
||
/** | ||
* Sample code to get the Signing Certificate for the vCenter Server. This | ||
* will enable users to view the certificate actively used to sign tokens and | ||
* certificates used for token signature verification. | ||
*/ | ||
public class GetSigningCertificate extends SamplesAbstractBase { | ||
private SigningCertificate certService; | ||
|
||
@Override | ||
protected void parseArgs(String args[]) { | ||
super.parseArgs(new ArrayList<Option>(), args); | ||
} | ||
|
||
@Override | ||
protected void setup() throws Exception { | ||
this.certService = | ||
vapiAuthHelper.getStubFactory().createStub(SigningCertificate.class, | ||
sessionStubConfig); | ||
} | ||
@Override | ||
protected void run() throws Exception { | ||
Info certInfo= certService.get(); | ||
if(certInfo == null) | ||
{ | ||
System.out.println("ERROR: Signing certificates not found on this vCenter"); | ||
} | ||
System.out.println("vCenter signing certificate \n"+certInfo); | ||
} | ||
|
||
public static void main(String[] args) throws Exception { | ||
GetSigningCertificate get = new GetSigningCertificate(); | ||
get.execute(args); | ||
} | ||
|
||
@Override | ||
protected void cleanup() throws Exception { | ||
// No cleanup required | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/vmware/samples/vcenter/certificatemanagement/vcenter/README.md
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,20 @@ | ||
This directory contains samples for managing vCenter signing certificate: | ||
|
||
The samples were tested against vSphere 7.0.3 | ||
|
||
Author: Andrew Gormley <[email protected]> | ||
Date: 09/15/2021 | ||
|
||
### SigningCertificate Get operations | ||
Sample | Description | ||
------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------ | ||
vmware.samples.vcenter.certificatemanagement.vcenter.GetSigningCerificate.java | Demonstrates SigningCertificate Get operation which displays the active signing certificate chain and certificate chains used to verify token signatures. | ||
|
||
### SigningCertificate Refresh operations | ||
Sample | Description | ||
----------------------------------------------------------------------------|------------------------------------ | ||
vmware.samples.vcenter.certificatemanagement.vcenter.RefreshSigningCerificate.java | Demonstrates SigningCertificate Refresh operation which creates a new private key and certificate chain issued by VMCA for token signing, and displays the new certificate chain. | ||
|
||
### Testbed Requirement: | ||
One (1) vCenter Server | ||
The username being used to run the sample should have the Administrator Role. |
75 changes: 75 additions & 0 deletions
75
.../java/vmware/samples/vcenter/certificatemanagement/vcenter/RefreshSigningCertificate.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,75 @@ | ||
/* | ||
* ******************************************************* | ||
* Copyright VMware, Inc. 2021. All Rights Reserved. | ||
* SPDX-License-Identifier: MIT | ||
* ******************************************************* | ||
* | ||
* DISCLAIMER. THIS PROGRAM IS PROVIDED TO YOU "AS IS" WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, WHETHER ORAL OR WRITTEN, | ||
* EXPRESS OR IMPLIED. THE AUTHOR SPECIFICALLY DISCLAIMS ANY IMPLIED | ||
* WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, | ||
* NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. | ||
*/ | ||
package vmware.samples.vcenter.certificatemanagement.vcenter; | ||
|
||
import com.vmware.vcenter.certificate_management.X509CertChain; | ||
import com.vmware.vcenter.certificate_management.vcenter.SigningCertificate; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import org.apache.commons.cli.Option; | ||
|
||
import vmware.samples.common.SamplesAbstractBase; | ||
|
||
/** | ||
* Sample code to refresh the Signing Certificate for the vCenter Server. | ||
* Use the force option to attempt to force the refresh in environments | ||
* that would otherwise fail. On success, the new signing certificates | ||
* will be printed. | ||
*/ | ||
public class RefreshSigningCertificate extends SamplesAbstractBase { | ||
private SigningCertificate certService; | ||
protected boolean force; | ||
|
||
@Override | ||
protected void parseArgs(String args[]) { | ||
Option forceOption = Option.builder() | ||
.required(false) | ||
.argName("FORCE") | ||
.longOpt("force") | ||
.desc("Attempt to force refresh") | ||
.build(); | ||
List<Option> optionList = Arrays.asList(forceOption); | ||
super.parseArgs(optionList, args); | ||
|
||
this.force = parsedOptions.get("force") != null; | ||
} | ||
|
||
@Override | ||
protected void setup() throws Exception { | ||
this.certService = | ||
vapiAuthHelper.getStubFactory().createStub(SigningCertificate.class, | ||
sessionStubConfig); | ||
} | ||
|
||
@Override | ||
protected void run() throws Exception { | ||
X509CertChain newCert= certService.refresh(this.force); | ||
if(newCert == null ) { | ||
System.out.println("ERROR: refresh signing certificate did not return a certificate"); | ||
} else { | ||
System.out.println("New vCenter signing certificate \n"+newCert.toString()); | ||
} | ||
} | ||
|
||
public static void main(String[] args) throws Exception { | ||
RefreshSigningCertificate get = new RefreshSigningCertificate(); | ||
get.execute(args); | ||
} | ||
|
||
@Override | ||
protected void cleanup() throws Exception { | ||
// No cleanup required | ||
} | ||
} |