Search in sources :

Example 6 with SshConfig

use of com.venafi.vcert.sdk.certificate.SshConfig 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

SshConfig (com.venafi.vcert.sdk.certificate.SshConfig)6 Config (com.venafi.vcert.sdk.Config)1 VCertTknClient (com.venafi.vcert.sdk.VCertTknClient)1 SshCaTemplateRequest (com.venafi.vcert.sdk.certificate.SshCaTemplateRequest)1 Authentication (com.venafi.vcert.sdk.endpoint.Authentication)1