Search in sources :

Example 6 with SshCaTemplateRequest

use of com.venafi.vcert.sdk.certificate.SshCaTemplateRequest in project vcert-java by Venafi.

the class TppConnectorATForSSH method retrieveSshConfigFromCADN.

@Test
@DisplayName("TPP - Testing the retrieveSshConfig() method using CADN")
public void retrieveSshConfigFromCADN() throws VCertException, Exception {
    SshCaTemplateRequest req = new SshCaTemplateRequest().template(System.getenv("TPP_SSH_CADN"));
    // getting the sshConfig of the SSH Cert CA
    retrieveSshConfig(req);
}
Also used : SshCaTemplateRequest(com.venafi.vcert.sdk.certificate.SshCaTemplateRequest) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 7 with SshCaTemplateRequest

use of com.venafi.vcert.sdk.certificate.SshCaTemplateRequest in project vcert-java by Venafi.

the class TppTokenConnectorATForSSH method retrieveSshConfigWithoutCredentialsFromCADN.

@Test
@Tag("AuthenticationUnneeded")
@DisplayName("TPP - Testing the retrieveSshConfig() method without authentication using CADN")
public void retrieveSshConfigWithoutCredentialsFromCADN() throws VCertException, Exception {
    // Given this test is tagged as AuthenticationUnneeded, then the Authentication will not be performed
    SshCaTemplateRequest req = new SshCaTemplateRequest().template(System.getenv("TPP_SSH_CADN"));
    // getting the sshConfig of the SSH Cert CA
    retrieveSshConfigWithoutCredentials(req);
}
Also used : SshCaTemplateRequest(com.venafi.vcert.sdk.certificate.SshCaTemplateRequest) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName) Tag(org.junit.jupiter.api.Tag)

Example 8 with SshCaTemplateRequest

use of com.venafi.vcert.sdk.certificate.SshCaTemplateRequest in project vcert-java by Venafi.

the class TppTokenConnectorATForSSH method retrieveSshConfigFromCADN.

@Test
@DisplayName("TPP - Testing the retrieveSshConfig() method using CADN")
public void retrieveSshConfigFromCADN() throws VCertException, Exception {
    SshCaTemplateRequest req = new SshCaTemplateRequest().template(System.getenv("TPP_SSH_CADN"));
    // getting the sshConfig of the SSH Cert CA
    retrieveSshConfig(req);
}
Also used : SshCaTemplateRequest(com.venafi.vcert.sdk.certificate.SshCaTemplateRequest) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 9 with SshCaTemplateRequest

use of com.venafi.vcert.sdk.certificate.SshCaTemplateRequest in project vcert-java by Venafi.

the class SshConfigRetrieving method main.

/**
 * @param args
 */
public static void main(String[] args) {
    try {
        // replace it by the CADN or the CA Name
        String template = "<TPP_SSH_CA>";
        // replace it by the TPP User
        String user = "<TPPUSER>";
        // replace it by the TPP Password
        String password = "<TPPPASSWORD>";
        // replace it by the TPP URL
        String baseUri = "<TPP_URL>";
        // 1. Get a VCertClient for TPP setting the scope to "ssh:manage"
        // 1.a The Authentication is optional, but if that is not provided,
        // then the principals of the returned SshConfig object will not be retrieved.
        Authentication auth = Authentication.builder().user(user).password(password).scope("ssh:manage").build();
        Config config = Config.builder().connectorType(ConnectorType.TPP_TOKEN).baseUrl(baseUri).build();
        VCertTknClient client = new VCertTknClient(config);
        client.getAccessToken(auth);
        // 2. Get an instance of com.venafi.vcert.sdk.certificate.SshCaTemplateRequest class.
        SshCaTemplateRequest req = new SshCaTemplateRequest().template(template);
        // 3. Use the VCertClient method retrieveSshConfig() to retrieve the Config of the given
        // SSH CA on TPP.
        // 3.a Remember that Authentication is optional, but if that is not provided,
        // then the principals attribute of the returned SshConfig object will not be retrieved.
        SshConfig sshConfig = client.retrieveSshConfig(req);
        client.revokeAccessToken();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : VCertTknClient(com.venafi.vcert.sdk.VCertTknClient) Authentication(com.venafi.vcert.sdk.endpoint.Authentication) Config(com.venafi.vcert.sdk.Config) SshConfig(com.venafi.vcert.sdk.certificate.SshConfig) SshConfig(com.venafi.vcert.sdk.certificate.SshConfig) SshCaTemplateRequest(com.venafi.vcert.sdk.certificate.SshCaTemplateRequest)

Aggregations

SshCaTemplateRequest (com.venafi.vcert.sdk.certificate.SshCaTemplateRequest)9 DisplayName (org.junit.jupiter.api.DisplayName)8 Test (org.junit.jupiter.api.Test)8 Tag (org.junit.jupiter.api.Tag)4 Config (com.venafi.vcert.sdk.Config)1 VCertTknClient (com.venafi.vcert.sdk.VCertTknClient)1 SshConfig (com.venafi.vcert.sdk.certificate.SshConfig)1 Authentication (com.venafi.vcert.sdk.endpoint.Authentication)1